JavaScript Expressions and JavaScript Operators are very familiar with most popular programming languages like C, C++, or Java. In this free JavaScript tutorial we take an overview of the basic building blocks of JavaScript: operators, expressions, through rounds: JavaScript Regular Expressions, JavaScript Operators, JavaScript Assignment Operators, JavaScript Arithmetic Operators, JavaScript Comparison Operators, JavaScript Bitwise Shift Operators, JavaScript Logical Operators, JavaScript Conditional Operator, JavaScript Comma Operator, JavaScript void Operator, JavaScript typeof Operator.

- Demo
- Enlarge
- Reload
- New window

# Free iPage Web Hosting for First Year NOW

If you're still looking for a reliable web host provider with affordable rates, why you don't take a little of time to try iPage, only with

**, included**

__$1.89/month__**for the payment of**

__$500+ Free Extra Credits__**?**

__24 months ($45)__Over 1,000,000+ existisng customers can not be wrong, definitely you're not, too! More important, when you

**register the web hosting at iPage**through our link, we're going to be happy for resending a

**to you. That's awesome! You should try**

__full refund__**now! And contact us for anything you need to know about iPage.**

__iPage web hosting for FREE__

## JavaScript Assignment Operators

JavaScript Assignment operators are used to assign values to JavaScript variables. In many cases or instances JavaScript Assignment Operator is used to set a variable to a literal value, for example:

var studentName = "Max"; //studentName set to Max

var aNumber = 1982; //aNumber set to 1982

var isNumber = true; //isNumber set to true

Lets consider x=10 and y=5, the table below explains the advanced use of assignment operators:

Table 1 -JavaScript Assignment Operators |
|||

Operator |
Example |
Equivalent |
Result |

= | x=y | x=5 | |

+= | x+=y | x=x+y | x=15 |

-= | x-=y | x=x-y | x=5 |

*= | x*=y | x=x*y | x=50 |

/= | x/=y | x=x/y | x=2 |

%= | x%=y | x=x%y | x=0 |

<<= | x <<= y | x = x << y | x=320 |

>>= | x >>= y | x = x >> y | x=0 |

>>>= | x >>>= y | x = x >>> y | x=0 |

&= | x &= y | x = x & y | x=0 |

|= | x |= y | x = x | y | x=15 |

^= | x ^= y | x = x ^ y | x=15 |

## JavaScript Arithmetic Operators

Arithmetic operators are used to perform all the basic arithmetic operations between operands (inputs) i.e. variables and/or values.

Table 2 - JavaScript Arithmetic Operators |
|||

Operator |
Meaning |
Example |
Result |

+ | Addition | x=4+2 | x=6 |

- | Subtraction | x=4-2 | x=2 |

* | Multiplication | x=4*2x | x=8 |

/ | Division | x=5/2 | x=2.5 |

% | Modulus (remainder) | x=5%2 | x=1 |

++ | Increment | x=++5 | x=6 |

- | Decrement | x=-5 | x=4 |

## JavaScript Comparison Operators

JavaScript Comparison operators are used in logical statements to determine equality or difference between variables or values. JavaScript comparison Operators evaluates to a Boolean value indicating whether its comparison is true or false. Most of JavaScript's comparison operators should be familiar to elementary mathematics Comparison Operators.

Table 3 - JavaScript Comparison Operators |
|||

Operator |
Meaning |
Example |
Result |

< | Less than | 5 < 8 | true |

<= | Less than or equal to | 8 <= 5 | false |

> | Greater than | 8 > 3 | true |

>= | Greater than or equal to | 5 >= 5 | true |

!= | Not equal to | 8 != 5 | true |

== | Equal to | 9 == 5 | false |

=== | Equal to (identical) | 5 === '5′ | false |

!== | Not equal to | 5 !== '5′ | true |

## JavaScript Bitwise Shift Operators

JavaScript Bitwise Shift Operators are used to move (shift) bits around rather than set them. Bitwise shift operators take two operands. The first is the number to be shifted, and the second specifies the number of bit positions by which all the bits in the first operand are to be shifted. The direction of the shift operation is controlled by the operator used, << for left shift and >> for right shift.

Table 4 - JavaScript Bitwise Shift Operators |
||||

Operator |
Description |
Example |
Intermediate Step |
Result |

<< | Left shift | 4<<3 | 00000100 shifted to the left three spots and filled with zeros results in 00100000. | 32 |

>> | Right shift with sign extend | -9>>2 | 11110111 shifted to the right two spots and left-filled with the sign bit results in 11111101. | -3 |

>>> | Right shift with zero fill | 32>>>3 | 00100000 shifted to the right three spots and left-filled with 0 results in 00000100. | 4 |

## JavaScript Logical Operators

JavaScript Logical operators are used to determine the logic between variables or values. The logical operators && (AND), || (OR), and ! (NOT) are useful to combine such values together in order to implement more complicated logic. The most common use of the logical operators is to control the flow of script execution using conditional statement.

Table 5 - JavaScript Logical Operators |
||||

&& | true if both operands evaluate true; otherwise returns false. | var x=true, y=false; alert(x && y); // displays false | ||

|| | Returns true if either operand is true. If both are false, returns false. | var x=true, y=false; alert(x || y); // displays true | ||

! | If its single operand is true, returns false; otherwise returns true. | var x=true; alert(!x); // displays false |

## JavaScript Conditional Operator

JavaScript Conditional Operator evaluate eventually a condition to true or false. If expression evaluates true, if-true-statement is evaluated. Otherwise, if-false-statement is executed.

The basic syntax for JavaScript Conditional Operator:

(expression) ? if-true-statement : if-false-statement;

var x=7;

(x >> 5) ? alert("x is greater than 5") : alert("x is less than 5");

## JavaScript Comma Operator

The comma operator (,) allows multiple expressions to be strung together and treated as one expression. Expressions strung together with commas evaluate to the value of the right-most expression. JavaScript Comma Operator mostly use with for condition.

var a,b,c,d;

for(i=0; i<=10; i++)

{

//Some JavaScript Statements

}

## JavaScript void Operator

The void operator specifies an expression to be evaluated without returning a value.

var a=0;

a = void (d=56);

alert(a); // the value of 'a' will alert as 'undefined'

## JavaScript typeof Operator

The typeof operator returns a string indicating the data type of its operand.

var a=3

var name = "I Love JavaScript";

alert(typeof a); // alert 'number'

alert(typeof name); // alert 'string'

Table 6 - JavaScript typeof Operator Return Values |
||||

Type |
String Returned by typeof |
|||

Boolean | "boolean" | |||

Number | "number" | |||

String | "string" | |||

Object | "object" | |||

Function | "function" | |||

Undefined | "undefined" | |||

Null | "object" |

- Sent (0)
- New

Save up to 630$ when buy new iPhone 15

GateIO.gomymobi.com

Free Airdrops to Claim, Share Up to $150,000 per Project

https://tooly.win

Open tool hub for free to use by any one for every one with hundreds of tools

chatGPTaz.com, chatGPT4.win, chatGPT2.fun, re-chatGPT.com

Talk to ChatGPT by your mother language

Dall-E-OpenAI.com

Generate creative images automatically with AI

AIVideo-App.com

Render creative video automatically with AI