Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Topic: JavaScript

Max Time: 30 Minutes


Name:
Mobile No:
Q1: How would you make this work?
add(2, 5); // 7
add(2)(5); // 7
function add(a){
var a=a;
return function(b){
return a+b;
}
}

Q2: What value is returned from the following statement?


"i'm a Ravi ".split("").reverse().join("");
" ivaR a m'i"

Q3: What is the value of window.foo?


( window.foo || ( window.foo = "bar" ) );

bar

Q4: What is the outcome of the two alerts below?


var foo = "Hello";
(function() {
var bar = " World";
alert(foo + bar);
})();
alert(foo + bar);
Hello bar
Helloundefined

Q5: What is the value of foo.length?


var foo = [];
foo.push(1);
foo.push(2);
2

Q6: Explain how this works in JavaScript

i)

A new instance of an object is created and its prototype (exposed via the
__proto__ property) is set to the prototype property of the constructor function.
ii) The constructor function is invoked with the newly created object bound to the
this property.
iii) If the function does not return a value, this is returned implicitly.

Q7: Explain why the following doesn't work as an IIFE:


function foo(){ }();.

What needs to be changed to properly make it an IIFE?


(function foo(){ })();

Q8: Difference between:


function Person(){},
i) var person = Person()
ii) var person = new Person()
i: return undefined
ii: return Window object

Q9: What's the difference between .call and .apply?


Difference in passing parameters apply takes array of arguments and call takes
comma separated

Q10: What is the difference between == and ===?

You might also like