5. Which loop is guaranteed to run at least once?
Anonymous Quiz
63%
a) for loop
13%
b) while loop
25%
c) do...while
0%
d) for...of
6. Which of these is a function expression?
Anonymous Quiz
43%
a) function greet() { }
29%
b) let greet = function() { }
14%
c) greet() => { }
14%
d) def greet() { }
7. What does this refer to inside a regular function (not strict mode)?
Anonymous Quiz
0%
a) Always the global object
50%
b) The function itself
25%
c) Undefined
25%
d) The parent object
❤1
8. Which of these creates a copy of an array?
Anonymous Quiz
0%
a) let b = a;
40%
b) let b = [...a];
40%
c) let b = a; b[0] = 99;
20%
d) None of the above
9. Which array method is a higher-order function?
Anonymous Quiz
17%
a) push()
83%
b) filter()
0%
c) length
0%
d) pop()
10. What will this print?
setTimeout(() => console.log("Hello"), 0);
console.log("World");
setTimeout(() => console.log("Hello"), 0);
console.log("World");
Anonymous Quiz
33%
a) Hello World
50%
b) World Hello
17%
c) Error
0%
d) Hello only
12. What does JSON stand for?
Anonymous Quiz
0%
a) JavaScript Oriented Nodes
40%
b) Java Standard Object Notation
60%
c) JavaScript Object Notation
0%
d) Java Syntax Over Network
13. Which keyword is used inside a class to create objects?
Anonymous Quiz
33%
a) class
67%
b) constructor
0%
c) object
0%
d) init
14. What is the output?
Anonymous Quiz
20%
console.log(..."JS");
40%
a) "JS"
0%
b) J S
40%
c) Error
0%
d) ["J","S"]
15. Which is the correct way to fetch API data in modern JS?
Anonymous Quiz
0%
a) data = api.fetch("url");
100%
b) fetch("url").then(res => res.json()).then(data => console.log(data));
0%
c) fetch("url").data();
0%
d) new fetch("url");
16. What will this output?
for (let i = 0; i < 3; i++) { setTimeout(() => console.log(i), 100); }
for (let i = 0; i < 3; i++) { setTimeout(() => console.log(i), 100); }
Anonymous Quiz
60%
a) 0 1 2
20%
b) 3 3 3
0%
c) 0 0 0
20%
d) Error
17. What will this output?
for (var i = 0; i < 3; i++) { setTimeout(() => console.log(i), 100); }
for (var i = 0; i < 3; i++) { setTimeout(() => console.log(i), 100); }
Anonymous Quiz
100%
a) 0 1 2
0%
b) 3 3 3
0%
c) 0 0 0
0%
d) Error
18. What will this print?
const obj = { name: "Code", greet: () => console.log(this.name) };
obj.greet();
const obj = { name: "Code", greet: () => console.log(this.name) };
obj.greet();
Anonymous Quiz
0%
a) "Code"
100%
b) undefined
0%
c) Error
0%
d) "obj"
19. What does the spread operator (...) do in arrays?
Anonymous Quiz
67%
a) Merges multiple arrays into one
0%
b) Creates a loop
33%
c) Declares rest parameters
0%
d) Creates a closure
20. Which one is NOT a valid Promise state?
Anonymous Quiz
0%
a) pending
50%
b) fulfilled
0%
c) rejected
50%
d) aborted
21. What will this output?
Promise.resolve(1)
.then(x => x + 1) .then(x => { throw new Error("Oops") }) .catch(err => 999) .then(x => console.log(x));
Promise.resolve(1)
.then(x => x + 1) .then(x => { throw new Error("Oops") }) .catch(err => 999) .then(x => console.log(x));
Anonymous Quiz
0%
a) 1
67%
b) 2
33%
c) Error
0%
d) 999
22. Which is the correct way to declare a class in JS?
Anonymous Quiz
50%
a) class MyClass { constructor() {} }
25%
b) new class MyClass {}
25%
c) function class MyClass() {}
0%
d) def MyClass {}
23. What will this output?
class Animal { constructor(name) { this.name = name; } }
const a = new Animal("Dog"); console.log(typeof a);
class Animal { constructor(name) { this.name = name; } }
const a = new Animal("Dog"); console.log(typeof a);
Anonymous Quiz
33%
a) "function"
67%
b) "object"
0%
c) "class"
0%
d) "Animal"
24. Which keyword is used to inherit from another class?
Anonymous Quiz
0%
a) super
17%
b) this
17%
c) extends
67%
d) inherits
25. Which DOM method selects the first matching element?
Anonymous Quiz
0%
a) getElementById()
25%
b) getElementsByClassName()
75%
c) querySelector()
0%
d) querySelectorAll()