DEV Community

Discussion on: JavaScript object destructuring usages you must know

Collapse
 
kazuyastefan profile image
Stefan Grbic

I was playing a bit with at(), but it's not supported in all browsers.

const str = 'Kumquat'
const {length, last = str.split('').at(-1) } = str;

console.log(length) // 7
console.log(last) // 't' 
Enter fullscreen mode Exit fullscreen mode