Mid
From PDF
JavaScript
JavaScript
Newer ES features (ES7–ES14):?
Short answer: includes(), ** (ES7) async/await, Object.entries() (ES8) Object rest/spread, Promise.finally (ES9) Array.flat(), Object.fromEntries() (ES10) BigInt, ??, ?.
Explain a bit more
(ES11) replaceAll(), Promise.any() (ES12) at(), top-level await (ES13) Array.findLast(), findLastIndex() (ES14+) Checks if an array contains a specific element and returns true or false.
Example code
const result = arr.flatMap(x => [x, x*2]); console.log(result); // [1, 2, 2, 4, 3, 6] Converts an array of key-value pairs into an object. Example: const entries = [['name', 'Sandeep'], ['age', 30]];
let b = false; // AND assignment a &&= false; console.log(a); // false // OR assignment b ||= true; console.log(b); // true // Nullish assignment let c = null;
const lastEven = arr.findLast(x => x % 2 === 0); console.log(lastEven); // 6 Example – findLastIndex(): const arr = [1, 2, 3, 4, 5, 6];
div.innerHTML = "<p>Hello</p>"; // Inserts <p>Hello</p>
div.innerText = "<p>Hello</p>"; // Displays "<p>Hello</p>"
const el2 = document.querySelector("#myDiv"); // Same result
const div = document.createElement("div");
div.textContent = "Hello World"; document.body.appendChild(div); // Adds the div to body const div = document.querySelector("#myDiv");
div.style.backgroundColor = "lightblue";
return function(...args) {
const now = Date.now();
if (now - lastCall >= limit) {
const increment = x => x+1;
const compose = (f, g) => x => f(g(x));
const double = multiply.bind(null, 2);
const obj = { [sym]: 123 }; Generator functions use function* and can yield multiple values over time, allowing lazy evaluation. function* gen() { yield 1; yield 2; }
return factorial(n - 1, n * acc); // Tail call
} Shallow copy – Copies top-level properties only, nested objects remain referenced. Deep copy – Copies entire object structure, no references. const obj = { a: 1, b: { c: 2 } };
const shallow = { ...obj };
const deep = JSON.parse(JSON.stringify(obj)); JSON – JavaScript Object Notation, a lightweight data interchange format. const obj = { name: "John" };
const str = JSON.stringify(obj); // serialize
Say this in the interview
- Define — one clear sentence (the short answer above).
- Example — relate it to a project like ShopNest or your real work.
- Trade-off — when you would not use it.
Share this Q&A
Share preview image: https://www.toolliyo.com/images/toolliyo-logo.png