The increment (++) and decrement (--) operators in JavaScript are used to increase or decrease the value of a variable by 1, respectively. They are unary operators, meaning they work on a single operand. The increment (++) and decrement (--) operators can be used in two forms: postfix and prefix. The difference lies in when the increment or decrement operation takes place in relation to the variable.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Tutor Joes</title> </head> <body> <script src="js/script.js"></script> </body> </html>To download raw file Click Here
// Increment (++) or Decrement (--) let a=1; a++; //a=a+1 console.log(a); let b=5; b--; //b=b-1; console.log(b); /* PostFix Increment a++ Prefix Increment ++a */ let x=3; const y=x++; //3 console.log("X : ",x,"Y : ",y); let i=3; const j=++i; console.log("I : ",i,"J : ",j);To download raw file Click Here
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions