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

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

Final Group Sadhana with HariHaran Mani

Today's meditation was drive down the memory lane. The events of the past few months/years simple drizzled in and out. The location had been flat#508 Cassia block in Brigade Millennium. The flat was on rental by  +Hariharan Mani , an +Art of Living  teacher, actuarial practitioner and meditator from Mumbai. It was here that we began our Group Sadhana about a year and half back. Today's idea was from  +Balakrishnan Ganesan  and original idea was from Shuchi. All of us are in photo above. Yesterday Bala said, lets do it for one last time. He messaged again that we had to bring our own yoga mats. There was a time when we had kept one carpet for morning Group Sadhana at Hari's flat. People joined and left us at different points of time. I remembered that Agnihotra Homa was to be performed at sunrise so messaged back that my entry would be delayed. In the end we gave a moist eyes good byes to Mr Hari and his bangalore stay. His memories and common moments will remain wi

सोहम का महत्व - live ashtavakra by Sri Sri RaviShankarji

मैं वही हूँ. न मैं त्रितिये व्यक्ति मैं हूँ, न द्वितीये व्यक्ति मैं हूँ. मैं खुद खुदा हूँ. सो हम. यह नाम तुम्हे दिया गया है. यह तुम नहीं हो. एक बार एक संत जंगल के बीच मैं अपनी झोपड़ी मैं थे. तब वहां कोई ढेर सारा खाना लेके आ गया. उन्हें हैरानी हुई कि ऐसा क्यूं हुआ. तभी वहां ३-४ लोग आये ओर उनसे कहा कि हम भूखे हैं, हमें भोजन चाह्यिये. संत  ने कहा कि मिल जाएगा. वह लोग हैरान हुए ओर कहा कि यहाँ तो कुछ नज़र नहीं आता है. तब संत ने कहा कि "सच है कि मेरे पास कुछ नहीं है, लेकिन मैं जिसके पास हूँ उनके पास सब कुछ है. "   माँ बच्चे  को जन्म देने से पहले ही उसमें दूध आ जाता है. प्रकृति का नियम है कि जहाँ प्यास होनी होती है वहां पहले से पानी व्याप्त होता है. यह दूसरी बात है कि आपको  दीखता नहीं है.   आप पूर्ण हो क्यूंकि आप पूर्ण से बने हो ओर पूर्ण मैं रहते हो ओर पूर्ण मैं जाना है. पूर्ण मैं से पूर्ण को निकालने से क्या पूर्ण अधूरा हो जाता है. आप अकेले से बोर क्यूं होते हैं, क्यूंकि आप ने अपने आप को नीरस कर दिया है. आपके पास जिस परमात्मा को होना था वह आपको कहीं ओर दीखता है. आपके पास