ECMAScript (ES10)

|
| By Webner

ECMAScript is the standard for JavaScript and adding new features to JavaScript.
It is a subgroup of JavaScript. ECMAScript 10 is also known as ES10. In ES10 here are the new features.

  1. Array.Flat(): The flat() function recursively flatten your array up to the level you specify, you have to use flat() function once if you want to flatten the array into one level and if you do it twice it would flatten by two levels.
    if you want to flatten the whole array then you need to use simple with infinity level. For example: array.flat(Infinity).
    ECMAScript code-01
  2. Array.FlatMap(): The FlatMap() function maps each element of an array by using a mapping function and returns the flattened array as a result.
    ECMAScript
  3. Object.fromentries() – This method converts a list of key-value pairs into an object.
    ECMAScript code-03
  4. String.trimStart() & String.trimEnd():
    • String.trimStart()- This function is used to remove the whitespace from the beginning of a string.
    • String.trimEnd()- This function is used to remove the whitespace from the end of a string
  5. Optional catch binding: In ES10 scripts we can use try-catch without any binding means we can use the catch function without params. Earlier, it mandatory to use params with a catch block
    code-04
  6. Well Formed JSON.stringify(): In ES10, JSON.stringify() update fixes processing of characters U+ D800 through U+DFFF and prevents this function from returning ill formed Unicode strings.
  7. Enhancement in toString() function: The toString() method returns a string representing the source code of the function. White spaces, new lines, and comments were removed and now they are retained with original source code.
    code-05
  8. Symbol Description: Symbol is the data type in javascript and symbol.description() is the new addition in Es10 to read-only property description added to Symbol object and new accessor added by providing a string as a description. There are many ways to create the symbol description.

    For example:

    • Using Symbol constructor : const symbol=new Symbol(optionalDescription)
    • Symbol.for() method : Symbol.for('global desc').description;

Leave a Reply

Your email address will not be published. Required fields are marked *