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?...
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...
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';...
I can access a PHP var with Javascript like this:  <?php     $fruit = "apple";     $color = "red"; ?>  <script type="text/javascript">     alert("fruit: " + "<?php echo $fruit; ?>"); // or s...
I have a piece of JS code to generate random numbers and output them as variables to be used here in place of the rotation values  @-webkit-keyframes rotate {     0% {-webkit-transform: rotate(-10deg);}     100% {-webkit-transform: rotate(10deg);}...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.