Learning ES6 for React. Write Your Answer here

Learning ES6 for React. Write Your Answer here.

1 Like

What is ES, ES5 and ES6 ?

Write down es6 feature ?

ES stands for ECMAScript.ECMAScript is a standardized scripting language specification, and it forms the basis for several programming languages, including JavaScript.

ES5 (ECMAScript 5) is the fifth edition of the ECMAScript standard, released in 2009. It introduced significant features to JavaScript, including strict mode, JSON support, new array methods, and getters and setters for objects.

ES6 is major version of ECMASCRIPT language specification.It introduced significant enhancements to JavaScript, including arrow functions, classes, const and let declarations for block-scoping, template literals, and more, making JavaScript more powerful and expressive for modern web development.

1 Like

ES 6 Features:-

1.Arrow function
3.Template Literals
4.Let And Const
6.Spread operator

1 Like
  1. JavaScript was originally named JavaScript in hopes of capitalizing on the success of Java.
  2. Netscape then submitted JavaScript to ECMA International for Standardization. (ECMA is an organization that standardizes information)
  3. This results in a new language standard, known as ECMAScript.

Put simply, ECMAScript is a standard. While JavaScript is the most popular implementation of that standard. JavaScript implements ECMAScript and builds on top of it.

Okay, so ‘ES’…?

ES is simply short for ECMAScript. Every time you see ES followed by a number, it is referencing an edition of ECMAScript.

ES5 definition:
ES5 stands for ECMAScript 5, which is a version of the ECMAScript programming language specification. ECMAScript is the standard on which JavaScript is based, defining the syntax and semantics of the language.

ES5 was released in December 2009 and introduced significant changes and improvements to the JavaScript language. It was a significant milestone in the evolution of the JavaScript language and laid the foundation for subsequent versions, such as ES6 (ECMAScript 2015), ES7 (ECMAScript 2016), and so on.

ES6 definition:
ES6, also known as ECMAScript 2015, is a version of the ECMAScript programming language specification. It is a significant update to the JavaScript language, introducing numerous new features and improvements. ES6 was published in June 2015 and has since become widely adopted by browsers and supported by modern JavaScript environments.
The release of ES6 marked a significant milestone for JavaScript, bringing many modern programming language features to the language and enhancing its usability, readability, and maintainability.
ES6 allows you to write the code in such a way that makes your code more modern and readable. By using ES6 features, we write less and do more, so the term ‘Write less, do more’ suits ES6.

1 Like

Why ES6 is more popular over its new version?
ES6 (ES2015) gained popularity and widespread adoption for several reasons:

  1. Rich feature set: ES6 introduced numerous new features and improvements to the JavaScript language, addressing many pain points and limitations of previous versions. The addition of features like arrow functions, template literals, destructuring assignment, and modules made JavaScript code more concise, readable, and maintainable.
  2. Browser support: ES6 introduced features that were eagerly awaited by developers, and browser vendors started implementing these features rapidly. The support for ES6 features in modern browsers improved significantly, making it feasible for developers to start using ES6 in their projects without worrying about compatibility issues.
  3. Tooling and transpilation: As the popularity of ES6 grew, tooling and build systems evolved to support the new syntax and features. Transpilers like Babel allowed developers to write code using ES6 syntax and then convert it to ES5-compatible code, ensuring broader compatibility across different environments.
  4. Community and ecosystem support: The developer community quickly embraced ES6, creating resources, tutorials, and libraries that showcased and utilized the new features. Frameworks and libraries started adopting ES6 as the default syntax, further driving its adoption.

It’s worth noting that ECMAScript has continued to evolve beyond ES6/ES2015, with newer versions such as ES7 (ES2016), ES8 (ES2017), ES9 (ES2018), ES10 (ES2019), ES11 (ES2020), ES12 (ES2021), and ES13 (ES2022). Each new version brings additional features and improvements to the language, but ES6 had a significant impact and laid the foundation for the subsequent versions.

Features of ES6:
ES6 (ECMAScript 2015) introduced numerous new features and improvements to the JavaScript language. Here are some key features of ES6:

  1. let and const: ES6 introduced block-scoped variables with the let and const keywords. let allows variable reassignment within its block scope, while const creates read-only constants.
  2. Arrow functions: Arrow functions provide a concise syntax for writing functions. They have implicit returns and lexically bind the value of this. Arrow functions are especially useful for short and callback-style functions.
  3. Template literals: Template literals allow the creation of multi-line strings and string interpolation. Variables and expressions can be embedded directly within a string using ${} syntax.
  4. Destructuring assignment: Destructuring assignment enables extracting values from arrays or objects and assigning them to variables using a concise syntax. It simplifies working with complex data structures.
  5. Enhanced object literals: ES6 introduced several enhancements to object literals. Shorthand property and method definitions allow concise object creation. Computed property names enable dynamic property names.
  6. Modules: ES6 introduced native support for modules. Modules allow developers to organize their code into reusable and separate files. They have their own scope and can explicitly export and import values from other modules.
  7. Iterators and generators: ES6 introduced the concept of iterators and generators. Iterators provide a standard way to traverse data collections, while generators are functions that can be paused and resumed. They simplify working with sequences and asynchronous programming.
  8. Promises: Promises provide a standardized way to handle asynchronous operations. They represent the eventual completion (or failure) of an asynchronous task and allow chaining and handling of results more easily than traditional callback-based approaches.
  9. Classes: ES6 introduced a more convenient syntax for defining classes and working with prototypes. Classes provide a way to define object blueprints with methods and properties.
  10. Default parameters and rest parameters: ES6 introduced default parameter values, allowing function parameters to have default values if not explicitly provided. Rest parameters enable capturing multiple function arguments as an array.
  11. Spread syntax: The spread syntax allows an iterable (like an array or string) to be expanded into individual elements. It can be used in function calls, array literals, and object literals.
1 Like

ES(ECMAScript):-A standard for scripting languages, including JavaScript, JScript, and ActionScript
ES5:-ECMAScript 2009, also known as ES5, was the first major revision to JavaScript.
Variables. In ES5, there is a one way of defining variables using var keyword

ECMAScript 2015 was the second major revision to JavaScript.
ECMAScript 2015 is also known as ES6 and ECMAScript 6.


1.Define Objects. ES6 provides easy way to define objects when the keys and the variable names are same.
2.The let keyword allows you to declare a variable with block scope.
3.The const keyword allows you to declare a constant, Constants are similar to let variables, except that the value cannot be changed.
4.Arrow functions do not have their own this. They are not well suited for defining “object methods”
Arrow functions are not hoisted
5.The … operator expands an iterable (like an array) into more elements:
6.The rest parameter (…) allows a function to treat an indefinite number of arguments as an array
7.ES6 allows function parameters to have default values.

1 Like

ECMAScript is the scripting language standardized by Ecma International. In short, ECMAScript is a language specification.

Many languages follow and implement the ECMAScript specification, e.g., JavaScript, ActionScript, Nashorn.

ECMAScript is commonly used for client-side scripting on the World Wide Web , and it is increasingly being used to write server-side applications and services using Node.js and other runtime environments.
ES5 is also known as ECMAScript 2009 as it is released in 2009.
For ES5 you have to write function keyword and return, to be used to define the function, like normal general JavaScript language.
There are only one way to define the variables by using the var keyword.
It supports primitive data types that are string, number, boolean, null, and undefined.
Object manipulation is time-consuming in ES5.
ES6 is also known as ECMAScript 2015 as it is released in 2015. Its class allows the developers to instantiate an object using the new operator, using an arrow function, in case it doesn’t need to use function keyword to define the function, also return keyword can be avoided to fetch the computer value.
There are two new ways to define variables that are let and const.
In ES6, there are some additions to JavaScript data types. It introduced a new primitive data type ‘symbol’ for supporting unique values.
Object manipulation is less time-consuming in ES6.

1 Like

ES6 features:
let and const
Arrow functions
Destructuring assignment
Template string literals
Default parameters
Merging objects
Arrow functions

1 Like

I feel Now You guys are Good With ES6 Features. Let’s Talk more about ES6. #brace #yourself #for #react

1 Like



1 Like

ES is a short form used for ECMAScript.It is a standardized scripting language specification, and it forms the basis for several programming languages, including JavaScript.
ES5 - is ECMA Script 5 and was developed in 2009.ES5 introduced significant features to JavaScript, including strict mode, JSON support, new array methods, and getters and setters for objects.
ES6 - is the ECMA script programming language, the next version after 5 was released in 2015. It is used to create the standards for JavaScript language such that it can bring multiple independent implementations.

1 Like

Let and const
Arrow functions
Spread operator
Destructing assignment
Template literals
Default parameters
Rest parameters

1 Like

What is ES ,ES5,ES6?

1 Like

Difference between ES5 and ES6?

1 Like

ES6 feature.

1 Like

@najmindalwale20 Nice handwritten notes :heart_decoration:

1 Like
 -> ECMA acronym European Computer Manufacturer’s Association.
 -> It means ECMAScript was written by Brendan Eich at Netscape. & numbers denotes version of the ECMAScript language specification provides significant updation to Javascript language.
 -> ECMAScript is a scripting language specification on which JavaScript is based. ECMA International is an organization is in charge of standardizing ECMAScript.
 -> Generally, ECMAScript is used for client-side scripting of the World Wide Web.

 -> It means ECMAScript Dec'2009
 -> ES5 supports primitive data types that are string, number, boolean, null, and undefined.
 -> In ES5, we could only define the variables by using the var keyword.
 -> As ES5 is prior to ES6, there is a non-presence of some features, so it has a lower performance than ES6.
 -> A wide range of communities supports it.
 -> ES5 is time-consuming than ES6.
 -> In ES5, both function and return keywords are used to define a function.
 -> In ES5, there is a use of for loop to iterate over elements.

 -> It means ECMAScript 2015 has proverb "Write less, do more" as it utilizes reusability. ES7  means ECMAScript 2016.
 -> In ES6, there are some additions to JavaScript data types. It introduced a new primitive data type 'symbol' for supporting unique values.
 -> In ES6, there are two new ways to define variables that are let and const.
 -> Because of new features and the shorthand storage implementation ES6 has a higher performance than ES5.
 -> It also has a lot of community support, but it is lesser than ES5.
 -> Due to destructuring and speed operators like spread & rest, object manipulation can be processed more smoothly in ES6.
 -> An arrow function is a new feature introduced in ES6 by which we don't require the function keyword to define the function.
 -> ES6 introduced the concept of for...of loop to perform an iteration over the values of the iterable objects.

The latest version is ES14 means ECMAScript July'2023
Advantages of ES 6 over ES 5 ?
1) Managing variables 
2)  Scope and Hoisting 
3) Overcome callBack hell by promises and async-await functions
ES6 Feature:-
 -> Async - Makes any function to return the promises. The function hello will return a promise.
 -> Await - Name itself implies, it makes javascript to wait till the operation is done.
 -> Let's say you are making API request with await keyword, it makes to wait until you receives the response and resumes the execution.
 -> Await function can be used only inside the async operation, outside it will not work.
           Eg1:- async function hello() {
                  let response = await fetch("URL");
                  //above line fetches response from given API endpoint.
                  return response;
                 hello(); // Calling async function
                 // catching promise thrown/returns by async-await function via 
                 .then(function(x) {
          Output: Response from the API.
          Explanation: We have used await while fetching response from API. 
              The fetch operation may take few seconds to get response.
              So till that execution will be halted and resumes later.

                       Eg2:- async function hello() {
                              return "Hello Promise..!"    
     => Above code defines an async function and returned some value or returned some error.
     => If you are returning some value in the async function, it is equivalent to calling resolve function.
     => If you are returning some error by calling error constructor (i.e) using ‘new’then it is equivalent to reject function.
     => Don’t forget that async function will return a promise. So of course, you can call resolve and reject function inside async function too.


     => Above code using Promise both are equal
           function hello() {
              return new Promise(function(resolve, reject) {
                 // executor function body.
 -> Promises : Promises are objects that helps to do async operations.
 -> Life Cycle of Promises (Three states in Promises)
     (1) Pending : Just executing the async operation. 
               In this state promises can move to either FulFilled or Rejected state.
     (2) Fulfilled: Means async Operation is complete (we have the output)
     (3) Rejected: Means async Operation is Not successful & We have the error which caused the operation to fail.
 -> “Promise defined by creating a constructor using new keyword”, then constructor will have executor function.
            SYNTAX - Promise
               const apiCall = new Promise(function(resolve, reject) {
                      // async operation is defined here...
              .then(function(x) {  // Resolve 
              .catch(function(x) { // Reject 

  => Note: Executor Function has two parameters (resolve, reject).
  => Resolve : Actually a function it represents the async operation is successful and we have got the output. “It helps Promise to move from Pending to FulFilled State ”.
  => Reject : Like Resolve , its also a function it represents the async operation is not successful and we have got the error. “It helps Promise to move from Pending to Rejected State ”

 -> let & const keywords used instead of var due to their block scope nature & cannot be reassigned. It has to be initialised while declaration itself.
 ->  As var is functional scope nature, .
 -> Const is for single assignment, used for immutable(not-modifiable) variables and used only when there are no further changes to the variable.
 -> Template Literal is used to work with strings by interpolation. Strings within Backticks used with Variables inside ${variable}. No longer has to use + for String concatenation.
      Eg:-  `str1 ${variable} str2`;
 -> Spread Operator (...) is used to merge arrays and objects. This spreads the content of any array.
 -> Rest Operator(...) is used to represent an indefinite amount of arguments as an array in the function parameter. In simple terms, it gathers elements (parameters of the function) into an array.
 -> Arrow functions makes code more readable, structured and simpler. It can be used in other built-in functions like map(), filter() & reduce()
 -> Default Parameters in ES6 allows us to set default parameters which prevents from undefined values in arrow function.
    Eg:- const rewardPoint = (name, point=50) => {
               return `${name} has been rewarded: ${point} points.`;
           console.log(rewardPoint('Monisha')); // Monisha has been rewarded: 50 points.
   => Here 50 is default value given by developer inside parameter.
 -> Classes that is closer to a Object-Oriented Programming (OOP) style using the “class” keyword and supports inheritance as well. In ES5, one defines property using “prototype”.
 -> Modules Import / Export helps us to import / export values to/from modules without global namespace pollution. There are 2 types: Named and Default.
 -> Default exports can only have, at most, one value to be exported. It can be imported with any name. There can only be 1 export statement in default export.
 -> Name exports are distinguished by their name. The class, variable, or functions that are exported using name export, can only be imported using the same name. Additionally, name export can allow multiple variables and functions to be imported and exported.
1 Like