www.pickatutorial.com Computer Tutorials
Top eBooks: C/C++ | C# | Android | Mathematics | Database | Cloud | Graphics | Networking | Oracle | Hardware | AI
Top Tutorials: C/C++ | C#.NET | PHP MySQL | Java | Java Script | jQuery | HTML | xHTML | HTML5 | VB Script| CSS
Lessons JavaScript Shorthand Assignment Operators Bookmark and Share
Tutorial Home
Lesson 1
Lesson 2
Lesson 3
Lesson 4
Lesson 5
Lesson 6
Lesson 7
Lesson 8
Lesson 9
Lesson 10
Lesson 11
Lesson 12
Lesson 13
Lesson 14
Lesson 15
Lesson 16
Lesson 17
Lesson 18
Lesson 19
Lesson 20
Lesson 21
Lesson 22
Lesson 23
Lesson 24
Lesson 25
Lesson 26
Lesson 27
Lesson 28
Lesson 29
Lesson 30
Lesson 31
Lesson 32
Lesson 33
Lesson 34
Lesson 35
Lesson 36
Lesson 37
Lesson 38
Lesson 39
Lesson 40
Lesson 41
Lesson 42
Lesson 43
Lesson 44
Lesson 45
Lesson 46
Lesson 47
Lesson 48
Lesson 49

In this lesson we will discuss about the shorthand assignment operators used in JavaScript programming language.

An assignment operator (=) assigns a value to the operand of its left hand side based on the value of its right hand side e.g. a = b, assigns the value of b to a and a = 8 assigns the value 8 to a.

It is very common to write:

a = a + b;
a = a * b;

Note that in the above lines of JavaScript code we have written a twice in each line. We can avoid this by using the shorthand forms for assignment operators. The following table lists the various shorthand assignment operators available in JavaScript:

Short-hand operator Long hand form
 a += b  a = a + b
 a -= b  a = a - b
 a *= b  a = a * b
 a /= b  a = a / b
 a %= b  a = a % b
 a <<= b  a = a << b
 a >>= b  a>>= b
 a >>>= b  a = a >>> b
 a &= b  a = a & b
 a ^= b  a = a ^ b
 a |= b  a = a | b

Next >>> Lesson No. 42: JavaScript Operator Precedence





Home - Advertise - Contact - Disclaimer - About Us
© Since 2006 pickatutorial.com -- All Rights Reserved.