πŸ“Š JavaScript
Q. Consider the following code snippet :
The state stored in q is :
Code:
var p = counter(), q = counter(); 
p.count()
q.count() 
p.reset() 
p.count() 
q.count()
  • (A) Undefined
  • (B) Null
  • (C) 0
  • (D) 1
πŸ’¬ Discuss
βœ… Correct Answer: (D) 1
πŸ“Š JavaScript
Q. What is the difference between the two lines given below ?
Code:
!!(object1 && object2);
(object1 && object2);
  • (A) Both the lines checks just for the existence of the object alone
  • (B) The first line results in a real boolean value whereas the second line merely checks for the existence of the objects
  • (C) Both the lines result in a boolean value “False”
  • (D) Both the lines result in a boolean value “True”
πŸ’¬ Discuss
βœ… Correct Answer: (B) The first line results in a real boolean value whereas the second line merely checks for the existence of the objects
πŸ“Š JavaScript
Q. For the below mentioned code snippet:
The equivalent statement is
Code:
var obj = new Object();
  • (A) Object obj=new Object();
  • (B) var obj= new Object;
  • (C) var obj;
  • (D) var obj = Object();
πŸ’¬ Discuss
βœ… Correct Answer: (B) var obj= new Object;
πŸ“Š JavaScript
Q. If you have a function f and an object o, you can define a method named m of o with
  • (A) obj=fun.meth;
  • (B) obj=fun;
  • (C) obj.meth=meth.fun;
  • (D) obj.meth=fun;
πŸ’¬ Discuss
βœ… Correct Answer: (D) obj.meth=fun;
πŸ“Š JavaScript
Q. The one-liner code that concatenates all strings passed into a function is
  • (A) function concatenate() { return String.concat.apply('', arguments); }
  • (B) function concatenate() { return String.prototype.concat('', arguments); }
  • (C) function concatenate() { return String.prototype.concat.apply('', arguments); }
  • (D) function concatenate() { return String.prototype.apply('', arguments); }
πŸ’¬ Discuss
βœ… Correct Answer: (A) function concatenate() { return String.concat.apply('', arguments); }
πŸ“Š JavaScript
Q. Consider the following code snippet :
Code:
var string2Number=parseInt("456pqr");
  • (A) 456pqr
  • (B) Exception
  • (C) NaN
  • (D) 456
πŸ’¬ Discuss
βœ… Correct Answer: (D) 456
πŸ“Š JavaScript
Q. Consider the following code snippet : will this code work?
Code:
var tensquared = (function(n) {return n*n;}(100));
  • (A) Exception will be thrown
  • (B) Memory leak
  • (C) Error
  • (D) Yes
πŸ’¬ Discuss
βœ… Correct Answer: (D) Yes
πŸ“Š JavaScript
Q. Do functions in JavaScript necessarily return a value?
  • (A) some functions do not return any value
  • (B) It is mandatory
  • (C) Not necessary
  • (D) Few functions return values by default
πŸ’¬ Discuss
βœ… Correct Answer: (D) Few functions return values by default
πŸ“Š JavaScript
Q. Consider the following code snippet :
Code:
var Total=eval("5*5+10");
  • (A) 35 as an integer value
  • (B) 35 as a string
  • (C) Exception is thrown
  • (D) 5*5+10
πŸ’¬ Discuss
βœ… Correct Answer: (A) 35 as an integer value
πŸ“Š JavaScript
Q. Consider the following code snippet.
Which is an equivalent code for the above code snippet?
Code:
opt.fun(p,q);
  • (A) opt.fun(p && q);
  • (B) opt(fun)["p","q"];
  • (C) opt.fun(p) && opt.fun(q);
  • (D) opt["fun"](p,q);
πŸ’¬ Discuss
βœ… Correct Answer: (D) opt["fun"](p,q);