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...

तुम दीन नहीं हो - live ashtavakra commentary by Sri Sri Ravishankar ji

तुम वही हो. तुम सूर्य कि किरण नहीं, तुम उस किरण का विस्तार हो. तुम सूर्य हो.  जिस प्रकार सूर्ये अपनी किरणों को हर खिड़की के माध्यम से हर घर मैं भेजता है, उसी प्रकार परमात्मा अपनी पूर्णता को छोटी छोटी आत्मायों मैं भेजता है.  यह बात दूसरी है कि जब आत्मा अपने पुर मैं वास करने लगती है, अपने शरीर रुपी घर मैं रहने  लगती है तो भूल जाती है कि वह सिमित नहीं है, उसका विस्तार ही परमात्मा है.  लेकिन घर मैं घुसने के बाद आप कांच के टुकड़े मैं सूर्य का प्रतिबिम्ब देखते हो ओर अपने आप को सिर्फ एक किरण मात्र समझने लगते हो. जरा बाहर झाँक कर भी देखो, सूर्य का अनुभव तो करो. तुम्हारे आस पास भी वही सूर्य का अंश है. तुम्हारे पड़ोस मैं भी वही सूर्य कि किरण है, तुम्हारे गाँव मैं जो रिश्तेदार हैं वहां भी वही सूर्ये है. सूर्य कोई भेद भाव नहीं करता. तुम क्यूं ऊँच- नींच मैं पड़े हो.  तुम्हारे दुःख का कारण  क्या है. तुम गुरु से तो मिले हो. तुमने गुरु को साक्षात् किया है. लेकिन तुम संपूर्णतः यह निश्चय नहीं कर पाए हो कि येही सत्य है. पूरे भरोसे कि कमी होने से ही दुःख होता है....

second day at school

The stomach did pain again and bu now she had learnt the art of unbuckling the belt. Fortunately the pain came up just as her father was opening the door. The mother came rushing and wanted to help but the strict father wanted her child to master the art of releasing the belt and walk the distance towards potty on her own. The child did not disappoint and fulfilled the fathers desire in aplomb. to school. They went to the car together. Poor father carrying the bag full of books and the daughter carrying the empty bag as they were hopeful that something would come back in it from school. As they were moving out of their apartment complex the father eyes turned to the side and saw a lady with more than usual broad smile. He wanted to be the good man and stopped the car. He was sliding down the side window and almost opened his mouth then he heard " Are you going to school? ". " Ofcourse, I was with my daughter in the back seat. Where else could I be heading? " The fat...