Member-only story

Cool ES2019 features this year!

Avery Duffin
2 min readJul 2, 2019

--

This year es6 is releasing some new features! Some people like to live years in the future. But most of us want to only start adopting the most important things here and now.

Here’s some of the features that you can start using. Much of this is taken from the article published by Faraz Kelhini here. Also you can check out the actual white-paper here.

Object.fromEntries()
trimStart()
trimEnd()
flat()
flatMap()

What do each of these do for us.

Object.fromEntries()

basically Object.fromEntries() is the opposite of Object.entries(). Object.entries() if you didn’t know converts an object into a list of tuples. So Object.fromEntries() converts a list of tuples back into an object.

For example:

Object.entries()

const obj = {foo: 1, bar: 2, zee: 3};

console.log(Object.entries(obj));
// [["foo", 1], ["bar", 2], ["zee", 3]]

Object.fromEntries()

const arrOfTuples = [["foo", 1], ["bar", 2], ["zee", 3]];console.log(Object.fromEntries(arrOfTuples))
// {foo: 1, bar: 2, zee: 3}

In most cases you probably dont need to convert between the two. But one of the coolest ways you can use this is in url params.

--

--

Avery Duffin
Avery Duffin

Written by Avery Duffin

Im a software engineer, react developer, inventor, salesman, family man, religious, and outdoor connoisseur

No responses yet