
Operators in Java Script-Arthematic,Assigment,Logical
JavaScript Operators with Examples JavaScript operators are symbols used to perform operations on variables and values. They are mainly used for calculations, assigning values, and checking conditions . The most commonly used operators are: Arithmetic Operators Assignment Operators Logical / Comparison Operators 1) Arithmetic Operators Arithmetic operators are used for mathematical calculations. Operator Meaning Example Output + Addition 10 + 2 12 - Subtraction 10 - 2 8 * Multiplication 10 * 2 20 / Division 10 / 2 5 % Modulus 10 % 3 1 Example let a = 10 ; let b = 2 ; console . log ( a + b ); // 12 console . log ( a - b ); // 8 console . log ( a * b ); // 20 console . log ( a / b ); // 5 console . log ( a % b ); // 0 Type Casting Example console . log ( 10 - " 2 " ); // 8 Here JavaScript converts "2" (string) into number 2. This is called type casting / type coercion. Increment and Decrement Operators These operators increase or decrease a value by 1 . Operator Meaning ++ Increment -- D
Continue reading on Dev.to JavaScript
Opens in a new tab


