In this video we have discuss about one of the core and important concepts which is used in in the Java Script.
(INCREMENT OPERATOR )
The increment (++) operator increments (adds one to) its operand and returns the value before or after the increment, depending on where the operator is placed.
The ++ operator is overloaded for two types of operands: number and BigInt. It first coerces the operand to a numeric value and tests the type of it. It performs BigInt increment if the operand becomes a BigInt; otherwise, it performs number increment.
If used postfix, with operator after operand (for example, x++), the increment operator increments and returns the value before incrementing.
If used prefix, with operator before operand (for example, ++x), the increment operator increments and returns the value after incrementing.
The increment operator can only be applied on operands that are references (variables and object properties; i.e. valid assignment targets). ++x itself evaluates to a value, not a reference, so you cannot chain multiple increment operators together.
let x = 3;
const y = x++;
// x is 4; y is 3
let x2 = 3n;
const y2 = x2++;
// x2 is 4n; y2 is 3n
let x = 3;
const y = ++x;
// x is 4; y is 4
let x2 = 3n;
const y2 = ++x2;
// x2 is 4n; y2 is 4n
(Decrement Operator)
The decrement (--) operator decrements (subtracts one from) its operand and returns the value before or after the decrement, depending on where the operator is placed.
The -- operator is overloaded for two types of operands: number and BigInt. It first coerces the operand to a numeric value and tests the type of it. It performs BigInt decrement if the operand becomes a BigInt; otherwise, it performs number decrement.
If used postfix, with operator after operand (for example, x--), the decrement operator decrements and returns the value before decrementing.
If used prefix, with operator before operand (for example, --x), the decrement operator decrements and returns the value after decrementing.
The decrement operator can only be applied on operands that are references (variables and object properties; i.e. valid assignment targets). --x itself evaluates to a value, not a reference, so you cannot chain multiple decrement operators together.
Postfix decrement
JS
Copy to Clipboard
let x = 3;
const y = x--;
// x is 2; y is 3
let x2 = 3n;
const y2 = x2--;
// x2 is 2n; y2 is 3n
Prefix decrement
JS
Copy to Clipboard
let x = 3;
const y = --x;
// x is 2; y = 2
let x2 = 3n;
const y2 = --x2;
// x2 is 2n; y2 is 2n
We hope that you all like the video. Do share and subscribe the channel.
#javascript
#code #coding
#css
#html
#javascripttutorials
#codelover
#codelife
#codeschool
#increment
#decrement
#webdeveloper
#webdevelopment
#web
Sur cette page du site, vous pouvez voir la vidéo en ligne Increment And Decrement Operators In Java Script | Complete Java Script Tutorials| #9 durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Utkarsh Gupta 25 juin 2023, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 47 fois et il a aimé 2 téléspectateurs. Bon visionnage!