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

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

Pay Online Property Tax Bangalore BBMP

Once again the time comes to pay tax to government . I called Mr. Shivappa who offers his services after office hours to residents of Brigade Gardenia. He asked me to come to the newly constructed BBMP help center in RBI layout, behind Capital School on 2nd Main. I could not locate it the first time and the good old postman on the Luna asked me to sit behind him and turned back from his onward journey of dropping letters to show me the place. To our dismay the help center was right in front of us after 2 sec ride. Mr. Shivappa who had explained me the address of the place and also asked me to come there with previous two years receipt, khata and blank cheque . I requested him to disclose the amount so that I can pay it online. He did not. He asked my the flat area and then ignored my bodily existence. When I was in front of him requesting the same information he suddenly stopped understanding my Hindi and English . A good samaritan who was standing nearby explained to him that...