JavaScript: Problems added in January 2016


Problem 2016-01-17-04-52

complexity: 2 ; importance: 5; author: docentmail

Question: What would be alert messges for the code snippet?

alert(typeof myFunction);
alert(typeof OtherFunction);

function myFunction(){
  alert("Hello from myFunction ");
}

var myOtherFunction = function() {
       alert("hello from local myFunction");  
};


Problem 2016-01-17-04-41

complexity: 2 ; importance: 8; author: docentmail

Question: Is this valid to call function before it is declared?

myFunction();
function myFunction(){
  alert("Hello from myFunction ");
}


Problem 2016-01-17-04-15

complexity: 5 ; importance: 4; author: docentmail

Question: What would be result of execution of the snippet?

function myFunction(){
  alert("Hello from myFunction ");
}

function testFunctionHoisting(){
   alert(typeof myFunction);
    
   myFunction();  

   var myFunction = function() {
       alert("hello from local myFunction");  
   };
}
testFunctionHoisting();


Problem 2016-01-17-03-49

complexity: 2 ; importance: 5; author: docentmail

Question: What would be the alert message for the code snippet?

alert(aVar);
var aVar=5;


Problem 2016-01-17-03-36

complexity: 2 ; importance: 8; author: docentmail

Question: Give the code snippet that declares variable aVar with value 10 in local scope and not visible in Global scope


Problem 2016-01-17-01-28

complexity: 2 ; importance: 8; author: docentmail

Question: What would be result of execution of the snippet?

var theVar="value0";     
for (var i=0; i<10; i++) { 
     var theVar="value1";
}

alert(theVar);


Problem 2016-01-17-01-18

complexity: 2 ; importance: 8; author: docentmail

Question: What would be the result of execution of the snippet?

function func1() { 
     var theVar="value1";
}

func1();
alert(theVar);


Problem 2016-01-17-01-01

complexity: 2 ; importance: 8; author: docentmail

Question: What would be result of execution of the snippet?

function func1() { 
     theVar="value1";
}

func1();

alert(theVar);


Problem 2016-01-17-00-27

complexity: 2 ; importance: 8; author: docentmail

Question: What would be result of execution of the snippet?

var theVar = 'value0'; 
 
function func1() { 
var theVar="value1";
  function func2() { 
     alert(theVar);
  }
  func2();
}
func1();


Problem 2016-01-17-00-01

complexity: 2 ; importance: 8; author: docentmail

Question: What would be result of execution of the snippet?

function func1() { 
   function func2() { 
       var theVar = 'Bye !'; 
       alert(theVar);
   }
}
func2();


Problem 2016-01-16-19-43

complexity: 2 ; importance: 8; author: docentmail

Question: Give the code snippet that declares variable aVar with value 10 in Global scope


Problem 2016-01-15-00-26

complexity: 2 ; importance: 5; author: docentmail

Question: Give code snippets with assignment operators.


Problem 2016-01-15-00-12

complexity: 1 ; importance: 4; author: docentmail

Question: Give the code snippet to declare (or define) variable myVar but not initialize it. What is value of the variable?


Problem 2016-01-14-23-45

complexity: 2 ; importance: 5; author: docentmail

Question: Name reserved keywords of JavaScript


Problem 2016-01-14-18-21

complexity: 2 ; importance: 5; author: docentmail

Question: Which of the names of variables are correct?

2things
something4you
my_variable_name
aaa+bbb
...
 


Problem 2016-01-14-18-07

complexity: 2 ; importance: 4; author: docentmail

Question: Name main parts (or aspects) of variable


Problem 2016-01-14-17-38

complexity: 1 ; importance: 7; author: docentmail

Question: Give sample of JavaScript code block