Q. Which of the following are closures in Javascript?

  • (A) Variables
  • (B) Functions
  • (C) Objects
  • (D) All of the above
πŸ’¬ Discuss
βœ… Correct Answer: (D) All of the above

Q. What will be the output of the following code snippet?

Code:
print(parseInt("123Hello"));
print(parseInt("Hello123"));
  • (A) 123 NaN
  • (B) 123Hello Hello123
  • (C) NaN NaN
  • (D) 123 123
πŸ’¬ Discuss
βœ… Correct Answer: (A) 123 NaN

Q. What will be the output of the following code snippet?

Code:
a = [1, 2, 3, 4, 5];
print(a.slice(2, 4));
  • (A) 3, 4
  • (B) 2, 3
  • (C) 3, 4, 5
  • (D) 2, 3, 4
πŸ’¬ Discuss
βœ… Correct Answer: (A) 3, 4

Q. What will be the output of the following code snippet?

Code:
let sum = 0; 
const a = [1, 2, 3];
a.forEach(getSum);
print(sum);
function getSum(ele) {
   sum += ele;
}
  • (A) 6
  • (B) 1
  • (C) 2
  • (D) None of the above
πŸ’¬ Discuss
βœ… Correct Answer: (A) 6

Q. The 3 basic object attributes in Javascript are

  • (A) Class, prototype, objects' parameters.
  • (B) Class, prototype, object's extensible flag.
  • (C) Class, parameters, object's extensible flag.
  • (D) None of these
πŸ’¬ Discuss
βœ… Correct Answer: (B) Class, prototype, object's extensible flag.

Q. Which function is used to serialize an object into a JSON string in Javascript?

  • (A) stringify()
  • (B) parse()
  • (C) convert()
  • (D) None of the above
πŸ’¬ Discuss
βœ… Correct Answer: (A) stringify()

Q. The process in which an object or data structure is translated into a format suitable for transferral over a network, or storage is called?

  • (A) Object Serialization
  • (B) Object Encapsulation
  • (C) Object Inheritance
  • (D) None of the above
πŸ’¬ Discuss
βœ… Correct Answer: (A) Object Serialization

Q. What does the ‘toLocateString()’ method do in JS?

  • (A) Returns a localised object representation.
  • (B) Returns a parsed string.
  • (C) Returns a localized string representation of an object.
  • (D) None of the above.
πŸ’¬ Discuss
βœ… Correct Answer: (C) Returns a localized string representation of an object.

Q. What will be the output of the following code snippet?

Code:
print(typeof(NaN));
  • (A) Object
  • (B) Number
  • (C) String
  • (D) None of the above
πŸ’¬ Discuss
βœ… Correct Answer: (B) Number

Q. What is the output of the following code snippet?

Code:
print(NaN === NaN);
  • (A) true
  • (B) false
  • (C) undefined
  • (D) Error
πŸ’¬ Discuss
βœ… Correct Answer: (B) false