Skip to main content

learning and debugging javascript

Debugging Javascript
1. Use Firebug -
a. There is a console output where in you can type statements like 2*3 and press ENTER.
i. "\u03c0" press ENTER and see what comes.
b. Console.log("what ever you want to dump in console") frees you from alert.
c. Once you get a error in console window then restarting firefox helps
2. FireFox - Tools - Error console
a. Repeat 1 a above and click on evaluate.
b. "\xA9" press ENTER and see what comes.
3. Browser window location bar
a. The place where you type http://dsteps.blogspot.com instead try
i. Javascript:10%2 and press ENTER.
ii. javascript:for (i=0,j=1,fib=j;fib<100;i=j,j=fib,fib=i+j){document.write(i+"+"+j+"="+fib+"
");}


Other notable facts
1. Functions are values that can be manipulated like datatypes. Thus they can store in variables, arrays and objects and can pass around as parameters too.
a. var sq = function(x){return x*x};
b. function sq(x){return x*x;}
c. Pont a and b are same.
2. If you don’t initialize a var variable then its value is undefined.
3. If you don’t use var then variable declaration is global even though it may be in function body and may conflict with a global name.
4. Variable declarations are not restricted by block. Say a variable in loop will be visible outside the loop too and is defined for the entire function body. Effectively hiding or masking the global variable with same name. Initialization can happen anywhere in function body with another var declaration and assignment.
5. Reading value of an undeclared variable will cause runtime error as they are undefined. Assigning value to undeclared variable is done by implicit declaration in global scope.

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