Category: 2. JavaScript Operators
-
Operator Precedence
In JavaScript, operator precedence ensures the priority of the operators to be executed when a single expression contains multiple operators. So, whatever expressions have higher priority, the compiler executes it first over other operators and then executes the operators with the lower precedence. Whenever you write any JavaScript expression with only 1 or 2 operators, you can…
-
Exponentiation Operator
Exponentiation Operator The exponentiation operator in JavaScript is represented as **. The exponentiation operator takes two operands and returns the power of the first operand raised to the second. The exponentiation operator can also accept the variables of the BigInt data type as operands. Also, it follows the property of associativity, which means a**b**c and a**(b**c) expressions…
-
Spread Operator
What is a Spread Operator? The JavaScript spread operator () allows us to spread out elements of an iterable such as an array. The spread operator is represented with three dots (). This is operator is introduced in ES6. The main use cases of the spread operator are to copy array elements, concatenate arrays or objects with…
-
Yield Operator
JavaScript Yield Operator The yield operator in JavaScript is used to pause and resume the generator function asynchronously. In JavaScript, generator functions are the special functions that you can pause or resume while executing. The generator functions are defined with the ‘function*’ syntax. The yield keyword can only be used within the generator function that contains it. The yield operator pauses…
-
Grouping Operator
JavaScript Grouping Operator The grouping operator in JavaScript controls the precedence of the evaluation in expressions. It is denoted by parenthesis (), and you can put the expression inside that to change the expression evaluation order. It helps to evaluate an expression with lower precedence before an expression with higher precedence. Syntax You can follow the syntax…
-
Comma Operator
JavaScript Comma Operator The comma operator (,) in JavaScript evaluates the multiple expression from left to right. You can use the resultant value of the left expression as an input of the right expression. After evaluating all expressions, it returns the resultant value of the rightmost expression. However, the comma operator is also used in the ‘for’…
-
Delete Operator
JavaScript Delete Operator The JavaScript delete operator deletes/ removes a property from an object. It removes the property as well as value of the property from the object. It works only with the objects not with the variables or functions. In JavaScript, an array is an object, so you can use the ‘delete’ operator to…
-
Safe Assignment Operator
JavaScript Safe Assignment Operator (?=) is a suggested new feature for JavaScript that makes it easier to handle errors in code. This operator helps developers deal with errors more simply, without having to use complicated try/catch blocks. It is denoted by (?=) symbol. It is currently under development and not yet part of the official ECMAScript specification. Syntax The…
-
Nullish Coalescing Operator
Nullish Coalescing Operator The Nullish Coalescing operator in JavaScript is represented by two question marks (??). It takes two operands and returns the first operand if it is not null or undefined. Otherwise, it returns the second operand. It is a logical operator introduced in ES2020. In many cases, we can have the null or empty values stored in the…
-
typeof Operator
The typeof Operator The typeof operator in JavaScript is a unary operator used to get the data type of a particular variable. It is placed before its single operand, which can be of any type. Its returns a string value indicating the data type of its operand. JavaScript contains primitive and non-primitive data types. There are seven…