What is the scope of variables in javascript? Do they have the same scope inside as opposed to outside a function? Or does it even matter? Also, where are the variables stored if they are defined globally?...
Why does the following work?  <something>.stop().animate(     { 'top' : 10 }, 10 );   Whereas this doesn't work:  var thetop = 'top'; <something>.stop().animate(     { thetop : 10 }, 10 );   To make it even clearer:...
I know it's possible in PHP to have "variable" variables.  For example  $x = "variable"; $$x = "hello, world!"; echo $variable; // displays "hello, world!"   Is it possible to refer to a variable by its name as a...
Given this snippet of JavaScript...  var a; var b = null; var c = undefined; var d = 4; var e = 'five';  var f = a || b || c || d || e;  alert(f); // 4   Can someone please explain to me what this technique is called (my best guess is in th...
Which method of checking if a variable has been initialized is better/correct? (Assuming the variable could hold anything (string, int, object, function, etc.))  if (elem) { // or !elem   or  if (typeof(elem) !== 'undefined') {   or  if (el...
How can I create static variables in Javascript?...
I know in PHP we can do something like this:  $hello = "foo"; $my_string = "I pity the $hello";   Output: "I pity the foo"  I was wondering if this same thing is possible in JavaScript as well. Using variables inside strings...
So for example:  function(input){     var testVar = input;     string = ...     string.replace(/ReGeX + testVar + ReGeX/, "replacement") }   But this is of course not working :) Is there any way to do this?...
I wanted to check whether the variable is defined or not. For example, the following throws a not-defined error    alert( x );   How can I catch this error?...
What are the differences and/or advantages, if any, of using commas when declaring a group of variables rather than semicolons.  For example:  var foo = 'bar', bar = 'foo';   versus  var foo = 'bar'; var bar = 'foo';...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.