It seems that the strict equality operator is strictly adhered to whenever possible - I put my code in JSLint and got the following feedback.
the code:
function log() { console.log(arguments.length == 1 ? arguments[0] : arguments); }
Feedback from JSLint:
Problem at line 2 character 34: Expected '===' and instead saw '=='.
I am curious to know which benefits === exceed == here. Basically, .length returns a Number , and 1 returns Number . You can be 100% sure, therefore === is just an extra extra token. In addition, type checking while you know that types will always be the same also has no performance advantages.
So what really is the reason for using === here?
javascript equality jslint types
pimvdb
source share