JavaScript Assignment Operator



Assignment

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

Syntax

= symbol is used for assignment operator.

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);