Question 41
MediumWhat is the output of this program?
const counter = (() => { let c = ; ++c; })();
(); ();
.(());
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Programming Languages
What is the output of this program?
const counter = (() => { let c = ; ++c; })();
(); ();
.(());
3
1
2
undefined
Sign up free to see the answer and a step-by-step explanation.
What is the output of this program?
console.log(0 == "0", 0 === "0", null == undefined, null === undefined, NaN == NaN);
false false true false true
true false false false false
Sign up free to see the answer and a step-by-step explanation.
What is the output of this program?
const arr = [1, 2, 3, 4, 5];
const r = arr.filter(x => x % 2).map(x => x * x).reduce((s, x) => s + x, 0);
console.log(r);
55
15
Sign up free to see the answer and a step-by-step explanation.
What is the output of this program?
let x = 1;
{
let x = 2;
x++;
}
var y = 1;
{
var y = 2;
}
console.log(x, y);
1 2
3 2
Sign up free to see the answer and a step-by-step explanation.
What is the output of this program?
const p = new Promise((res, rej) => { rej("bad"); res("good"); });
p.then(v => console.log("ok", v)).catch(e => console.log("err", e));
err bad
ok good
Sign up free to see the answer and a step-by-step explanation.
What is the output of this program?
console.log([..."hello"].reverse().join(""), Array.from({length: 3}, (_, i) => i * 2));
olleh [ 0, 2, 4 ]
hello [ 0, 1, 2 ]
Sign up free to see the answer and a step-by-step explanation.
What is hoisting in JavaScript?
Declarations are processed before code runs: var variables are created as undefined and function declarations are usable early
Making variables global
Lifting objects to the heap
Moving code to the server
Sign up free to see the answer and a step-by-step explanation.
What does 'use strict' change?
It disables functions
It makes code run faster always
It enables TypeScript
It turns some silent errors into thrown errors, for example assigning to an undeclared variable
Sign up free to see the answer and a step-by-step explanation.
What is the difference between null and undefined?
undefined is an object
null is a number
They are identical
undefined means a value was never assigned; null is an intentional 'no value' set by the programmer
Sign up free to see the answer and a step-by-step explanation.
What does async/await do in JavaScript?
Makes code run on several CPU cores
Lets asynchronous promise-based code be written in a sequential style
Blocks the event loop until a timer ends
Replaces callbacks with threads
Sign up free to see the answer and a step-by-step explanation.
true true true true false
true false true false false
35
9
1 1
2 2
ok bad
err bad ok good
olleh [ 2, 4, 6 ]
olleh [ 0, 1, 2 ]