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 Operator
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 Operator

ES6 Operator

Introduction to ES6 Operator

Es6 operator is a symbol that instructs the system to carry out a specific operation. There is a large set of operators in JavaScript, and you may execute any task by utilizing certain operators. The operators are used to evaluate distinct operands in expressions; a statement that returns a value is known as an expression. The spread operator, which is made up of three dots, was introduced in ES6 (…). It allows an Iterable to expand where more than zero arguments are expected. In addition, it grants us access to an array of parameters.

What is the es6 operator?

  • The syntax of the spread operator is similar to that of the rest parameter, but it is completely different.
  • Below is the syntax of the es6 spread operator is as follows.
Var name_of_variable = […value]
  • At the time of declaring any variable, we need to put the var keyword before any variable. The name of the variable parameter shows that variable name.
  • The spread operator targets full values in a variable, represented by the three dots (…), which is shown in the above syntax.
  • The spread operator divides an array into its constituent elements.
  • The spread operator debuted in JavaScript ES6. It decomposes the array into separate elements. As a result, it can be used to expand the array in areas where there should be zero or more elements.

Es6 operator

  • JavaScript contains the below list of operators are as follows.
  • Relational operator
  • Arithmetic operator
  • Assignment operator
  • Logical operator
  • Type operator
  • Bitwise operator
  • Miscellaneous operator
  • In JavaScript, every expression evaluates the value, and it will contain the operator and operands.

Arithmetic operator

Below is the arithmetic operator is available in JavaScript is as follows.

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

  • Addition (+): It will return the sum of two operand values. For example, if suppose A operand value is 5 and B operand value is 10, then the addition of two operands is 15.
  • Subtraction (-): It will return the difference of two operand values. For example, if suppose A operand value is 15 and B operand value is 10, then the subtraction of two operands is 5.
  • Multiplication (*): It will return the product of two operand values.
  • Division (-): It will return the quotient of two operand values.
  • Modulus (%) :It will return the remainder of two operand values.

Relational operator

Below is the relational operator available in JavaScript is as follows. The relational operator is defined as two entities’ relationship.

  • Greater than operator (>) –

If A is 10 and B is 15, then (A>B) is false.

  • Less than operator (<) –

If A is 10 and B is 15, then (A<B) is true.

  • Greater than equal to operator (>=) –

If A is 10 and B is 15, then (A>=B) is false.

  • Less than equal to operator (<=) –

If A is 10 and B is 15, then (A<=B) is true.

  • Equal to operator (==) –

If A is 10 and B is 15, then (A==B) is false.

  • Not equal to operator (!=) –

If A is 10 and B is 15, then (A!=B) is true.

Logical operator –

Below is the logical operator available in JavaScript is as follows. A logical operator is used to combine two or more conditions.

  1. Logical AND
  2. Logical OR
  3. Logical NOT

Bitwise operator –

Below is the bitwise operator available in JavaScript is as follows.

  1. Bitwise AND
  2. Bitwise OR
  3. Bitwise NOT
  4. Bitwise XOR
  5. Bitwise left shift
  6. Bitwise sign propagating right shift.
  7. Bitwise zero-fill right shift.

Assignment operator –

Below is the bitwise operator available in JavaScript is as follows.

  1. Simple assignment
  2. Add an assignment
  3. Subtract and assignment
  4. Multiply and assignment
  5. Divide and assignment

Miscellaneous operator

Below is the miscellaneous operator available in JavaScript is as follows.

  1. Negation operator
  2. String operator
  3. Conditional operator
  4. Typeof operator
  5. Spread operator

Es6 operator examples

Given Below is the example of the es6 operator:

Arithmetic operator example

Code –

var A = 100;
var B = 20 ;
console.log ("Addition of A and B is: " + (A + B));
console.log ("Subtraction of A and B is: " + (A - B));
console.log ("Multiplication is A and B is: " + (A * B));
console.log ("Division if A and B is: " + (A / B));
console.log ("Modulus of A and B is: " + (A % B));

ES6 Operator output 1

Relational operator example

Code –

var A = 25;
var B = 20;
console.log("A variable value is: " + A);
console.log("B variable value is: " + B);
var output = A > B;
console.log("A > B: " + output);
output = A < B;
console.log("A < B: " + output);
output = A >= B;
console.log("A >= B: " + output);
output = A <= B;
console.log("A <= B: " + output);
output = A == B;
console.log("A == B: " + output);
output = A != B;
console.log("A != B: " + output);

ES6 Operator output 2

Logical operator example

Code –

var P = 30;
var Q = 80;
console.log("P = " + P );
console.log("Q = " + Q );
var Output = ((P < 40) && (Q <= 90));
console.log("(P < 40) && (Q <= 90): ", Output);
var Output = ((P == 50) || (Q > 80));
console.log("(P == 50) || (Q > 80): ", Output);

ES6 Operator output 3

Assignment operator example

Code –

var P = 10;
var Q = 20;
P = Q;
console.log("P value:  " + P);
P += Q;
console.log("P+=Q: " + P);
P -= Q;
console.log("P-=Q: " + P);
P *= Q;
console.log("P*=Q: " + P);
P /= Q;
console.log("P/=Q: " + P);

output 4

Negation operator example

Code –

var A = 30;
var B = -A;
console.log("A value = " +A);
console.log("B value = " +B);

output 5

Spread operator example

Code –

const num = [10, 20, 30, 40, 50, 60];
const [one, two, ...rest] = num;
document.write("<p>" + one + "</p>");
document.write("<p>" + two + "</p>");
document.write("<p>" + rest + "</p>");

Output:

output 6

Conclusion

A statement is used to evaluate the value, which was referred to as an expression. Every sentence is made up of words. Operands are nothing but the variables which was used to represent the data. The operator is a component that performs actions on operands.

Recommended Articles

This is a guide to ES6 Operator. Here we discuss What is es6 operator is and the list of operators which are available in JavaScript. You may also have a look at the following articles to learn more –

  1. ES6 Features
  2. What is ES6?
  3. ES6 Interview Questions
  4. JavaScript Iterator
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

*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