JavaScript for Beginners

The Assignment Operator (=) assigns a value to a variable:

 

Example :

 

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Operators</h1>
<h2>The = Operator</h2>

<p id=”demo”></p>

<script>
let x = 10;
document.getElementById(“demo”).innerHTML = x;
</script>

</body>
</html>

 

Output

JavaScript Operators

The = Operator

10

 

Description :

In JavaScript, assignment refers to the process of storing a value in a variable. This is done using the assignment operator (=), which assigns the value on the right to the variable on the left.