Modern JavaScript in Node
Node supports modern JavaScript: let and const, arrow functions, destructuring, spread, template strings, optional chaining and nullish coalescing.
Example
const user = { name: 'Ada', address: { city: 'Lagos' } };
const { name, address: { city } } = user;
const nums = [1, 2, 3];
console.log(`${name} lives in ${city}`);
console.log([...nums, 4], user.phone?.number ?? 'no phone');Result
Ada lives in Lagos [ 1, 2, 3, 4 ] no phone
Exercise
Use the nullish operator.
x "default"
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.