DEV Community

Cover image for 6 Things you probably did not know javascript could do natively

6 Things you probably did not know javascript could do natively

Enmanuel Durán on September 24, 2019

Originally posted on Enmascript.com #Did you know is a new series of Enmascript where we write short and concise explanations about topics we cons...
Collapse
 
jay_wick profile image
Jay Wick

Just learnt about Object.seal! Nice!

Collapse
 
potouridisio profile image
Ioannis Potouridis

How about using Object Destructuring on arrays?

const data = [
    {
        id: 1,
        name: 'John'
    },
    {
        id: 2,
        name: 'Mary'
    }
]

const { 0: { id }, [data.length - 1]: last, length } = data;

// id => 1
// last => { id: 2, name: 'Mary' }
// length => 2
Collapse
 
jsn1nj4 profile image
Elliot Derhay

Wow. All that URL splitting I was doing before...

Collapse
 
abbiranjan profile image
Alok Ranjan

Just another great article.
Thanks a lot.

Collapse
 
kunjchoksi profile image
Kunj Choksi

Got to know about Object mutation and Object seal..
Thanks..