DEV Community

Anjali Gurjar
Anjali Gurjar

Posted on

JavaScript Memory Management Interview Questions

  1. Top-Level Await (ES13) In ES13, await can now be used at the top level in modules, allowing for cleaner asynchronous code without wrapping it inside an async function.

// index.mjs
const data = await fetch('https://api.example.com').then(res => res.json());
console.log(data);
Why it matters in interviews: This feature simplifies working with asynchronous code in modules and helps reduce boilerplate in modern applications.

Logical Nullish Assignment (??=)(ES12)
This is part of the logical assignment operators discussed above. The ??= operator only assigns the right-hand value if the left-hand value is null or undefined.

///////
Logical Nullish Assignment (??=)(ES12)
This is part of the logical assignment operators discussed above. The ??= operator only assigns the right-hand value if the left-hand value is null or undefined.

let x = null;
let y = 5;
x ??= y;
console.log(x); // 5 (because x was null)

let z = 0;
z ??= 10;
console.log(z); // 0 (because z was not null or undefined)
This is helpful when you want to set a default value only if the variable is null or undefined.

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay