JavaScript Common Mistakes

JavaScript programs may generate unexpected results if a programmer accidentally uses an assignment operator (=), instead of a comparison operator (==) in an if statement.

<p id="demo"></p>

<script>
var x = 0;
document.getElementById("demo").innerHTML = Boolean(x == 8);

</script>
This if statement returns false (as expected) because x is not equal to 8:

Комментарии

Популярные сообщения из этого блога

Code week

CCS Position

CSS Links