Monday, January 11, 2016

Some JavaScript Special Scenarios

for (i = 0,j=0; i < 3, j < 2; i++,j++) {
    console.log(i+" "+j)
}
The answer is 0,0 and 1,1 only j<2 applies
function f(a) {
  var a;
  alert(a);
}

f(4);
The answer is 4, since variable in javascript only has local and global scope

Original source
    for (i = 0,j=0; i < 3, j < 2; i++,j++) {
        console.log(i+" "+j)
    }

The answer is 0,0 and 1,1
only `j<2` applies


    function f(a) {
      var a;
      alert(a);
    }

    f(4);

The answer is 4, since variable in javascript only has local and global scope

No comments:

Post a Comment