Ramatou Adamou Issa

Ramatou Adamou Issa

  • Experiences
  • Formation
  • Musics
  • Blog

›Recent Posts

Recent Posts

  • Watchtower, container for updating docker images
  • PHP8 (Migrating existing PHP7 project to PHP8)
  • What news in Symfony 5
  • Command Query Segregation Responsibility (CQRS)
  • AFUP conference feedbacks

ES2019 features

May 7, 2019

Medium

What is new in ES2019 ( > Chrome 72)

Array flat


Create new array with all subArray elements

    const arrayTest = [1,2, [3, 4, [4, 6, [7, 8 ]]]

Flat level 1

    arrayTest.flat() //[ 1, 2, 3, 4, [ 4, 6 ] ]

Flat level 2

    arrayTest.flat().flat() //[ 1, 2, 3, 4, 4, 6, [7, 8]]

Flat infinity

    arrayTest.flat(infinity) //[ 1, 2, 3, 4, 4, 6 , 7, 8]

Array Flat Map


Map each element of array an then flattens the result into new array

    const arrayTest = [1, 2, 3, 4]

maps and flat

    const result = arrayTest.map(x => [x, x * 2]);
    
    // [ [ 1, 2 ], [ 2, 4 ], [ 3, 6 ], [ 4, 8 ] ]
    

Object form Entries


create object from array entries

    const arrayTest = [
  ['test1', 1],
  ['test2', 2],
  ['test3', 3]
]

Object entries

    const result  = Object.fromEntries(arrayTest)
    
    //{ "test1": 1, "test2": 2, "test3": 3 }

Strim Start & Strim End


start/end remove space form the beginning/end


const stringToTrim = '    test    ';


let result = stringToTrim.trimStart();
result = result.trimEnd()

//'test'

Optional catch binding


The error argument in the catch block is optional, Avoid creating unused binding

before

    try {
    } catch (error) {
        ....
    }

after

    try {
    } catch  {
        ....
    }

See more ES10 features here

Tweet
Recent Posts
  • What is new in ES2019 ( > Chrome 72)
Ramatou Adamou Issa
Ramatou Adamou Issa
HomeExperiencesFormation
Social Networks
InstagramTwitterChat
Accounts
Gallery photoBlogGitHubStar
Copyright © 2025 Ramazaki