Equality

Shane Brinkman-Davis Delamore edited this page Mar 29, 2018 · 3 revisions

Related: Semantics

Never use JavaScript's '=='

The normal JavaScript equality operator is highly unpredictable and can have a significant performance hit. In JavaScript, '123' == 123 is true, and costly to compute.

CaffeineScript Fixes Equality

Thankfully, JavaScript also has a high performance, easy-to-understand === operator. So CaffeineScript simply translates any '==' to '===':

# CaffeineScript:
a == b
# translates to JavaScript: a === b

a != b
# translates to JavaScript: a !== b

JavaScript does NOT have <==, etc.

However, JavaScript does NOT have an equivalent set of inequality operators.

CaffeineScript has plans to fix this, though it is more challenging. See: Operator Overloading

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.