Phil 1.23.13

8:00 – 4:00 ESSO

  • Backed up.
  • Rebuilt query spreadsheet for Dong
  • There may be a problem with PA, but it is more likely an older version. We’re adding in a test that checks the DB for the latest “Compiled” string and evaluates the date. If the local date is less than the DB date, the app throws up an “Update” dialog with instructions for FF and IE. If the date is greater, the app updates the string in the DB, otherwise things start normally.
  • Javascript!
  • Cool thing:
    var num = 0;
    outermost: // create a label for this for loop
    for (var i = 0; i < 10; i + +) {
        for (var j = 0; j < 10; j + +) {
            if (i == 5 && j == 5) {
                continue outermost; // go to the label
            }
            num ++;
        }
    }
    alert( num); // 95
  • Switch statements can switch on variables?
  • IMPORTANT!!! –
    • Function arguments in ECMAScript don’t behave in the same way as function arguments in most other languages. An ECMAScript function doesn’t care how many arguments are passed in, nor does it care about the data types of those arguments. Just because you define a function to accept two arguments doesn’t mean you can pass in only two arguments. You could pass in one or three or none, and the interpreter won’t complain. This happens because arguments in ECMAScript are represented as an array internally. The array is always passed to the function, but the function doesn’t care what (if anything) is in the array. If the array arrives with zero items, that’s fine; if it arrives with more, that’s okay too. In fact, there actually is an arguments object that can be accessed while inside a function to retrieve the values of each argument that was passed in.
    • Unlike in other languages, naming your arguments in ECMAScript does not create a function signature that must be matched later on; there is no validation against named arguments. The arguments object can also be used to check the number of arguments passed into the function via the length property. The following example outputs the number of arguments passed into the function each time it is called:
function howManyArgs() {
    alert( arguments.length);
}
howManyArgs(" string", 45); // 2
howManyArgs(); // 0
howManyArgs( 12); // 1
    • When a variable is declared using var, it is automatically added to the most immediate context available. In a function, the most immediate one is the function’s local context; in a with statement, the most immediate is the function context. If a variable is initialized without first being declared, it gets added to the global context automatically.
    • And in the “No Free Lunch Dept: Setting a variable to null effectively severs the connection between the variable and the value it previously referenced. The next time the garbage collector runs, these values will be deleted and the memory will be reclaimed. Even if you have garbage collection, it never hurts to help out.
    • As in other languages, ECMAScript arrays are ordered lists of data, but unlike in other languages, they can hold any type of data in each slot. This means that it’s possible to create an array that has a string in the first position, a number in the second, an object in the third, and so on.
    • Ringbuffer: ECMAScript also provides an unshift() method for arrays. As the name indicates, unshift() does the opposite of shift(): it adds any number of items to the front of an array and returns the new array length. By using unshift() in combination with pop(), it’s possible to emulate a queue in the opposite direction, where new values are added to the front of the array and values are retrieved off the back.
  • Hit the wall reading about functions. I need my ride, and it’s only 21 degrees!
  • Burned a disk with the new PA on it.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.