Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is a let variable equal to a var variable? [duplicate]

If I have something like:

let x = 20;
var z = 20;

will

x === z
like image 557
RadleyMith Avatar asked Sep 24 '15 14:09

RadleyMith


1 Answers

=== does not compare variables - it does compare values. Given that both your variables hold the same value (20), they will be "equal".

It does not matter for the equality how those variables were declared, only that both of them are in scope and have that value assigned when the === operation is evaluated. Which is the case in your example snippet.

like image 80
Bergi Avatar answered Sep 22 '22 21:09

Bergi