how to force variable declaration in javascript or how to check it? -


though can use variable without declaring in javascript, misuse of variable cause hard-to-solve errors. example, following code cause endless loop.

  for(i=0;i<100;i++){     document.write(fivetimes(i));   }   ...    function fivetimes(x){     i=5;     return (i*x);   } 

i'd know if there way force every variable in javascript declared before use. or knows how check variable declaration-before-using in tons of javascript files , blocks in huge web server.

you can enable "strict mode" , can pass code through jslint (or jshint if have sensitive feelings :))these steps go long way toward making code execute predictably.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -