6.3 KiB
JavaScript Technical Interview - Diagnostic Assessment
Purpose: Identify knowledge gaps to build a personalized 6-hour study curriculum Time: No time limit - answer based on current knowledge Instructions: Choose the best answer for each question. Do NOT research answers.
Section 1: Core Concepts & Fundamentals
Question 1
What will be logged?
console.log(typeof null);
- A) "null"
- B) "object"
- C) "undefined"
- D) "number"
Your answer: ___
A
Question 2
What is the output?
const arr = [1, 2, 3];
arr[10] = 11;
console.log(arr.length);
- A) 4
- B) 10
- C) 11
- D) undefined
Your answer: ___ C
Question 3
What gets logged?
function foo() {
console.log(this.bar);
}
const obj = { bar: 'hello', foo };
const fn = obj.foo;
fn();
- A) "hello"
- B) undefined
- C) ReferenceError
- D) null
Your answer: ___ B
Question 4
What is the result?
console.log(0.1 + 0.2 === 0.3);
- A) true
- B) false
- C) undefined
- D) NaN
Your answer: ___ A
Section 2: Closures & Scope
Question 5
What will be logged?
for (var i = 0; i < 3; i++) {
setTimeout(() => console.log(i), 100);
}
- A) 0, 1, 2
- B) 3, 3, 3
- C) undefined, undefined, undefined
- D) 0, 0, 0
Your answer: ___ A
Question 6
What is the output?
let x = 1;
function outer() {
let x = 2;
function inner() {
x++;
console.log(x);
}
return inner;
}
const fn = outer();
fn();
fn();
- A) 2, 2
- B) 3, 4
- C) 2, 3
- D) 1, 2
Your answer: ___ C
Section 3: Promises & Async
Question 7
What order will be logged?
console.log('1');
setTimeout(() => console.log('2'), 0);
Promise.resolve().then(() => console.log('3'));
console.log('4');
- A) 1, 2, 3, 4
- B) 1, 4, 2, 3
- C) 1, 4, 3, 2
- D) 1, 3, 4, 2
Your answer: ___ C
Question 8
What happens here?
async function foo() {
return 'hello';
}
console.log(foo());
- A) "hello"
- B) Promise {: "hello"}
- C) Promise {}
- D) undefined
Your answer: ___ C
Question 9
What will be the output?
Promise.resolve(1)
.then(x => x + 1)
.then(x => { throw new Error('error'); })
.catch(() => 3)
.then(x => console.log(x));
- A) 1
- B) 2
- C) 3
- D) Error is thrown
Your answer: ___ C
Section 4: Modern ES6+ Features
Question 10
What is logged?
const obj = { a: 1, b: 2, a: 3 };
console.log(obj.a);
- A) 1
- B) 2
- C) 3
- D) SyntaxError
Your answer: ___ A
Question 11
What is the result?
const arr = [1, 2, 3];
const [a, ...b, c] = arr;
console.log(b);
- A) [2]
- B) [2, 3]
- C) [1, 2, 3]
- D) SyntaxError
Your answer: ___ B
Question 12
What gets logged?
const obj = { x: 1 };
const copy = { ...obj };
copy.x = 2;
console.log(obj.x);
- A) 1
- B) 2
- C) undefined
- D) ReferenceError
Your answer: ___ A
Section 5: Objects & Prototypes
Question 13
What is the output?
const obj = Object.create(null);
console.log(obj.toString());
- A) "[object Object]"
- B) "null"
- C) undefined
- D) TypeError
Your answer: ___ C
Question 14
What will be logged?
function Person(name) {
this.name = name;
}
Person.prototype.greet = function() {
return `Hello ${this.name}`;
};
const p = new Person('Alice');
console.log(p.hasOwnProperty('greet'));
- A) true
- B) false
- C) undefined
- D) TypeError
Your answer: ___ A
Question 15
What is the result?
class Animal {
constructor() {
this.type = 'animal';
}
}
class Dog extends Animal {
constructor() {
this.breed = 'labrador';
super();
}
}
const dog = new Dog();
- A) dog.type is "animal"
- B) dog.breed is "labrador"
- C) ReferenceError
- D) Both properties are set correctly
Your answer: ___ D
Section 6: Array Methods & Iteration
Question 16
What is the output?
const arr = [1, 2, 3, 4];
const result = arr.map(x => x * 2).filter(x => x > 5);
console.log(result);
- A) [6, 8]
- B) [3, 4]
- C) [2, 4, 6, 8]
- D) [6]
Your answer: ___ A
Question 17
What gets logged?
[1, 2, 3].reduce((acc, val) => acc + val);
- A) 6
- B) "123"
- C) [1, 2, 3]
- D) undefined
Your answer: ___ A
Question 18
What is the result?
const arr = [1, 2, 3];
arr.forEach(x => {
if (x === 2) return;
console.log(x);
});
- A) 1, 3
- B) 1
- C) 3
- D) Nothing is logged
Your answer: ___ A
Section 7: Event Loop & Execution
Question 19
What order will be logged?
async function foo() {
console.log('1');
await Promise.resolve();
console.log('2');
}
foo();
console.log('3');
- A) 1, 2, 3
- B) 1, 3, 2
- C) 3, 1, 2
- D) 2, 1, 3
Your answer: ___ B
Question 20
What is the output?
console.log(1);
queueMicrotask(() => console.log(2));
Promise.resolve().then(() => console.log(3));
console.log(4);
- A) 1, 2, 3, 4
- B) 1, 4, 2, 3
- C) 1, 4, 3, 2
- D) 1, 3, 2, 4
Your answer: ___ B
Section 8: Tricky Scenarios & Edge Cases
Question 21
What will be logged?
const a = [1, 2, 3];
const b = [1, 2, 3];
console.log(a == b);
- A) true
- B) false
- C) undefined
- D) TypeError
Your answer: ___ A
Question 22
What is the result?
console.log([] + []);
- A) []
- B) ""
- C) undefined
- D) "[object Array][object Array]"
Your answer: ___ B
Question 23
What gets logged?
const obj = {
value: 42,
getValue: () => this.value
};
console.log(obj.getValue());
- A) 42
- B) undefined
- C) null
- D) ReferenceError
Your answer: ___ A
Question 24
What is the output?
console.log(+'42');
- A) "42"
- B) 42
- C) NaN
- D) undefined
Your answer: ___ B
Question 25
What will be logged?
let x = y = 10;
(function() {
let x = y = 20;
})();
console.log(y);
- A) 10
- B) 20
- C) undefined
- D) ReferenceError
Your answer: ___ A
Submission
Fill in your answers and save this file, then run the evaluation script or notify your instructor.
Answer Key Format:
1: B
2: C
3: A
4: B
5: B
6: B
7: C
8: B
9: C
10: C
11: D
12: A
13: D
14: B
15: C
16: A
17: A
18: A
19: B
20: B
21: B
22: B
23: B
24: B
25: B