JavaScript: Problems added in January 2016
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");
};
complexity: 2 ; importance: 8; author: docentmail
Question: Is this valid to call function before it is declared?
myFunction();
function myFunction(){
alert("Hello from myFunction ");
}
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();
complexity: 2 ; importance: 5; author: docentmail
Question: What would be the alert message for the code snippet?
alert(aVar); var aVar=5;
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
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);
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);
complexity: 2 ; importance: 8; author: docentmail
Question: What would be result of execution of the snippet?
function func1() {
theVar="value1";
}
func1();
alert(theVar);
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();
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();
complexity: 2 ; importance: 8; author: docentmail
Question: Give the code snippet that declares variable aVar with value 10 in Global scope
complexity: 2 ; importance: 5; author: docentmail
Question: Give code snippets with assignment operators.
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?
complexity: 2 ; importance: 5; author: docentmail
Question: Name reserved keywords of JavaScript
complexity: 2 ; importance: 5; author: docentmail
Question: Which of the names of variables are correct?
2things something4you my_variable_name aaa+bbb ...
complexity: 2 ; importance: 4; author: docentmail
Question: Name main parts (or aspects) of variable
complexity: 1 ; importance: 7; author: docentmail
Question: Give sample of JavaScript code block