4,500
edits
add more |
add more |
||
Line 1: | Line 1: | ||
=== examples === | === examples === | ||
Things to watch out for in automatic type conversion. | |||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> | ||
Line 10: | Line 10: | ||
NaN == NaN; // false use isNaN() function instead | NaN == NaN; // false use isNaN() function instead | ||
Number("5") * 5; // explicitly convert "5" to number and perform operation | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 15: | Line 17: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Automatic type conversion. To disallow automatic type conversion, use === or !== operators. | |||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> |