JavaScript Assignment Operator


Assignment

= symbol is used for assignment operator

assignment operator takes two operands, assigns the value of right hand side operand to the left hand side operand (variable)

a = 5  //assign value of 5 to a
a = b  //assign value in b to a

Examples

1. assign a with 5

var a = 5;
console.log(a);

2. assign a with value in b

var b = 7;
var a = b;
console.log(a);