JavaScript_MCQ_Coding_Snippets_2
JavaScript_MCQ_Coding_Snippets_2
var a = 10;
var b = "5";
console.log(a + b);
Options:
a. 15
b. "105"
c. NaN
d. Error
Options:
a. True
b. False
c. Undefined
d. SyntaxError
Options:
a. 1
b. 100
c. undefined
d. Error
4. What will be logged to the console?
var obj = { name: "John", age: 25 };
delete obj.name;
console.log(obj.name);
Options:
a. John
b. undefined
c. null
d. Error
Options:
a. No error, it logs 10
b. SyntaxError
c. TypeError
d. ReferenceError
Options:
a. "32"
b. "51"
c. "21"
d. 51
Options:
a. true
b. false
c. undefined
d. NaN
8. What will be the output of this code?
var a = 3;
function test() {
var a = 5;
console.log(a);
}
test();
Options:
a. 3
b. 5
c. undefined
d. ReferenceError
Options:
a. true
b. false
c. undefined
d. Error
Options:
a. 4
b. 5
c. "Hello"
d. Undefined
11. What does the following code print?
console.log(2 + "2" - 1);
Options:
a. "21"
b. 21
c. 3
d. NaN
Options:
a. [1, 2]
b. [1, 2, 3]
c. undefined
d. Error
Options:
a. true
b. false
c. undefined
d. NaN
Options:
a. true
b. false
c. undefined
d. NaN
15. What does the following code output?
console.log("5" - 3);
Options:
a. 53
b. 2
c. "2"
d. NaN