Skip to main content

some more javascript learning

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

Popular posts from this blog

Success is exchange of energy

The definition of success is very elusive. It means different things in different phases of life to different people. When I was in school and college it was to pass somehow. When I was in 12th it was to get into engineering somehow. When I was in job it was to make more money anyhow. When you were in marriage it was to demand happiness and feel proud in pronouncing to yourself that every act of a frustrating job was for the sake of family and their well being. I was focusing on doing. I was focusing on achievement. So whenever I reflected back in life I always felt less. I could have been an IITian, I could not crack CAT. I could not join an organization during their early stock offer days. I could not go to US and earn in dollars. I simply missed doing too many things.  Now I feel lack of achievement. Now I feel lack of doing. Did I miss out on something while I was undergoing all this doing? Why was I nervous all this while? Why did one achievement led to other? Why...

Shivani, Brahmakumaries and Aastha channel

She comes twice on TV from 7:10 PM to 7:40 PM and 10:30 to 11:00 PM on Aastha channel. The spiritual channel story in India is on same lines as that of Aaj Tak , which was run by local ads before the big boys put ads on them. Today Shivani, a Brahmakumari mentioned that 99% of the cause of anger and frustration is elsewhere, it is not in the spur of the moment, when you hurt somebody or get hurt by somebody. Instead of reacting instantaneously , or pestering the reaction in the mind post the incident till eternity , can you wonder "Why is that soul so angry, what is bothering her? I am sure there is something more than what she has told me now?". The chain of thoughts that emerge lead you to compassion, releases love vibrations into the air. Love has a very subtle medium to reach out. You cannot yell and throw around love and claim that you are helping somebody by your love. You have to surrender to love and let love take over. You cannot correct the world. You can onl...

fix for tweetmeme button on blogger

This was the second time when I was pained to locate a proper place to place the tweetmeme buton in blogger. The tutorial has suggested keeping it between b:loop values = 'data:posts' var = 'post'> and ‘b:loop’. Also there are two such places where you can place the code. If you place in lower one then it will appear only if ads appear in your blog. The above has not worked for me and I am not sure about you, do you Meme?. I searched for a place near the spans at end of post and put it above the below line " <p class='post-footer-line post-footer-line-2'> And it seems to work. You can meme below and retweet and check for yourself. Have you been struggling with button placement in blogger?