1. Label : any javascript statement including loops, conditionals, curly brackets blocks etc.,
a. Break:label; will take you to safety of label block
2. The break will bring you out of loop and continue will take you to new iteration in loop skipping the lower block. Continue first goes to increment than to condition statement in for loop whereas in while loop it goes to condition test directly.
3. Scope chain - every execution context has it. At top level its global and if not found object is undefined. In nested it includes the function call objects. The search begins in lowest scope and spreads out.
4. Create objects -- use object literal (comma separated property name value in curly bracket). An empty {} will declare a placeholder for referring object.
5. Object.property=value; is identical to object[property]=value; The first is used when you know name of property beforehand. The second is used for dynamic creation of property names.
a. Use double quotes when naming property inside [].
b. This is called as associative array and is generally iterated using
for(prop in objectarray){value=objectarray[prop];}
6. Create arrays - use array literals (a comma separated items in []).
a. The items maybe arbitrary expressions. They can embed object literals {}.
b. The length property is read(to know)/write(to expand).
7. String functions like sort, concat, split and splice modify array in place. Push and pop work at end of array and shift/unshift at start of array.
8. Nested functions declared using function keyword (statement--> function f(){return;}) can be in main body {} of function .
a. Function literals (var f = function(){return;})can come if conditionals and loop. They are like expressions only and require no name.
b. They can be named too like var x=function f(){return f();}. The reference to function is stored in x but it allows f to call itself by same name.
c. var ten = function(a){return a*a}(10);//ten is number.
d. var ten = function(a){return a*a};//ten is function().
Comments