Category: Math
Tests whether two values are equal.
Your apps will sometimes need to check if the values in their code are equivalent or not, and then possibly perform some specific action using an if, if-else, or while block. == returns true if the value on the left-hand side of the operator is equal to the value on the right-hand side of the operator.
// Basic numeric equality check. var x = 5; var y = 4; console.log(x == 5); console.log(x == y);
Example: "Alan Turing" equals "ALAN TURING"? Basic string equality check. Case matters for string comparison.
// Basic string equality check. Case matters for string comparison. var x = "Alan Turing"; var y = "ALAN TURING"; console.log(x == "Alan Turing"); console.log(x == y);
Example: 5 equals "5"? Numeric string to number conversion is automatic in App Lab.
// Numeric string to number conversion is automatic in App Lab. var x = 5; var y = "5"; if(x == y) { console.log("equivalent") } else { console.log("not equivalent") }
Example: 5 equals "five"? Word string to number conversion is not automatic in App Lab.
// Word string to number conversion is not automatic in App Lab. var x = 5; var y = "five"; if(x == y) { console.log("equivalent") } else { console.log("not equivalent") }
___ == ___
Name | Type | Required? | Description |
---|---|---|---|
___ | any | Yes | The operands can be a number/string/boolean, or a variable containing a number/string/boolean, or the number/string/boolean returned by a function, or the number/string/boolean result of the evaluation of an expression. |
Boolean true or false
Found a bug in the documentation? Let us know at documentation@code.org
__ == __
Boolean (true/false) is the left equal in value to the right.
Found a bug in the documentation? Let us know at documentation@code.org