Home | Mailing List | Blog | Tutorial Videos

String Operations and Array Destructuring

In the following example, we attempt to get part of our URL's domain name. What ends up being logged?

const url = 'quiz.typeofnan.dev';
const { length: ln, [ln - 1]: domain = 'quiz' } = url
  .split('.')
  .filter(Boolean);
console.log(domain);

Select one: