EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 600+ Courses All in One Bundle
  • Login
Home Software Development Software Development Tutorials ES6 Tutorial ES6 Cheat Sheet
Secondary Sidebar
ES6 Tutorial
  • ES6 Basic and Advance
    • What is ES6
    • ES6 Features
    • ES6 Enum
    • ES6 Array Methods
    • ES6 Spread Operator
    • ES6 Operator
    • ES6 Proxy
    • ES6 New Features
    • ES6 Set
    • ES6 reduce
    • ES6 Destructuring
    • ES6 filter
    • ES6 Cheat Sheet
    • ES6 Template Strings
    • ES6 Generators
    • ES6 Default Parameters
    • ES6 Object Destructuring
    • ES6 Arrow Function
    • ES6 Array
    • ES6 CLASSES
    • ES6 JavaScript
    • ES6 modules

ES6 Cheat Sheet

ES6 Cheat Sheet

Introduction to ES6 Cheat Sheet

ES6 provides different kinds of features to the user, in which that cheat sheet is one, the feature that is provided by ES6. Basically, the cheat sheet is nothing but the table of contents and that is used to replace the content of IIFE with the Block Arrow function as per our requirement. Black Arrow function includes the different types of functions such as String .includes() .repeat() etc. By using this template or function we can destructure arrays, object modules. The ES6 cheat sheet is basically implemented in modern projects and contemporary sample code as per our requirements.

What is ES6 cheat sheet?

The ES6 cheat sheet isn’t planned to show you JavaScript from the beginning, yet to assist engineers with essential information who might battle to get to know current codebases (or suppose to learn React for example) in light of the JavaScript ideas utilized.
Now let’s see different notations in the cheat sheet as follows.

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

Declaration of variable that is var, const, let

In Java, there are three different keywords available such as var, const, and let, let’s see them one by one as follows.

  • var: This is one of the variable declaration keywords in JavaScript, the scope of var is within the function and it is the mutable keyword.
  • let: This is the second keyword in the variable declaration and the scope of this keyword is within the block, it is also a mutable keyword.
  • const: This is a recommended variable in JavaScript and the scope of this keyword is within the block, it is also a mutable keyword.

Arrow Function

In ES6 it has a new feature that we call the arrow function that means it is another way to declare and use a function as per our requirement. It has some advantages such as it is more cosines, it is used to pick up the values from surroundings as per our requirement and it returns the implicit values.

Function with a default value of the parameter

In ES6 we can set the default value to the function as per our requirement by using the following syntax as follows.

Function specified function name (variable name = value){
return variable name;
}

Explanation

The default parameter we can use in two different situations such as if there is no parameter provided and if we need to provide the undefined parameter.

Now let’s see what is destructuring of objects and arrays.

Destructuring is an advantageous method of making new factors by removing a few qualities from information put away in articles or clusters. The destructuring can be utilized to destructure work boundaries or this. props in React anticipate for example.

Example

const student = {
name: “Johan”,
dept: “comp”,
city: “Mumbai”
}

Let’s consider the above code now. Let’s see how we can implement without destructuring as follows.

const stud_name = student.name;
const stud_dept = student.dept;
const stud_city = student.city || Mumbai;

Now let’s see with destructuring as follows.

const {name: name, dept, city = “Mumbai”} = student;

Explanation

In the above example, we write code with destructuring in one line as shown.

Function Parameters

Normally destructuring is used in functions for object parameters.

Array

We can also implement arrays with destructuring and without destructuring as per our requirement as well as we can also implement different array methods as follows.

  • Array.prototype.map(): takes a cluster, accomplishes something on its components, and returns an exhibit with the changed components.
  • Array.prototype.filter(): takes an exhibit, chooses component by component in case it should keep it or not, and returns a cluster with the kept components as it were.
  • Array.prototype.reduce(): takes an exhibit and totals the components into a solitary worth (which is returned).
  • Array.prototype.find(): takes a cluster, and returns the primary component that fulfills the given condition.

ES6 cheat sheet

Now let’s see different types of examples of ES6 cheat sheets for better understanding as follows.

First, let’s see the example of the arrow function as follows.

const add = (x, y) => x+y
console.log(add(6,6))

Explanation

In the above example, we try to implement the arrow function, here we first declare the arrow function of add with x and y variable with arrow function as shown. The final output of the above implementation we illustrated by using the following screenshot as follows.

2

Now let’s see the example of the default parameter as follows.

function print(x = 6){
console.log(a)
}
print()
print(10)

Explanation

In the above example, we try to implement the default parameters, here we created the print function to use default parameters with value as shown. After that, we try to print the default parameter and with value and without value. The final output of the above implementation we illustrated by using the following screenshot as follows.

3

Now let’s see an example of scope as follows.

let x = 5
if (true) {
let x= 7
console.log(x)
}
console.log(x)

Explanation

In the above example, we try to implement let scope, here we declare the same variable with different scope as shown. The final output of the above implementation we illustrated by using the following screenshot as follows.

4

Now let’s see how we can implement the string using const as follows.

const stud_name = 'Johan'
const msg = 'Welcome ${stud_name}'
console.log(msg)

Explanation

In the above example we implemented string with const, in this example we declared two variables with const as shown. The final output of the above implementation we illustrated by using the following screenshot as follows.

5

Now let’s string operations as follows.

String includes

By using the include() function we can get the specified result as per our requirement as follows.

console.log ('welcome'.includes('el'))

The final output of the above implementation we illustrated by using the following screenshot as follows.

6

console.log ('welcome'.includes('ab'))

The final output of the above implementation we illustrated by using the following screenshot as follows.

8

In string, we have another function that String startWith(), in that function we can find out the starting character of the string as per our requirement.

Conclusion

We hope from this article you learn more about the ES6 cheat sheet. From the above article, we have taken in the essential idea of the ES6 cheat sheet and we also see the representation and example of the ES6 cheat sheet. From this article, we learned how and when we use the ES6 cheat sheet.

Recommended Articles

This is a guide to ES6 Cheat Sheet. Here we discuss the definition, What is ES6 cheat sheet, Arrow Function, Example, and code. You may also have a look at the following articles to learn more –

  1. es6 modules
  2. ES6 Features
  3. What is ES6?
  4. ES6 Interview Questions
Primary Sidebar
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Java Tutorials
  • Python Tutorials
  • All Tutorials
Certification Courses
  • All Courses
  • Software Development Course - All in One Bundle
  • Become a Python Developer
  • Java Course
  • Become a Selenium Automation Tester
  • Become an IoT Developer
  • ASP.NET Course
  • VB.NET Course
  • PHP Course

ISO 10004:2018 & ISO 9001:2015 Certified

© 2023 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA Login

Forgot Password?

By signing up, you agree to our Terms of Use and Privacy Policy.

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more