Can I define multiple variables in JavaScript which rely on one another? -
i'm trying find out whether following code work (in implementations of javascript) , whether there concerns using it:
var query = window.location.search.substring(1), vars = query.split('&');
basically, js engine process variables in order in defined in js?
i using query variable elsewhere, otherwise define vars as
var pairs = window.location.search.substring(1).split('&');
in general, there 'concerns' both defining variable , assigning value in 1 fell swoop, comes more complex assignment?
there no concern, can use when define - there no problem. javascript hoists variables. whenever define variable, move top of current function. illustrate
(function(){ foobar = 3; // doesn't throw, since foobar in var statement, although it's later if(false){ var foobar = 5; } })();
Comments
Post a Comment