I'm using jslint.com to validate some functions and came across the error:
"A leading decimal point can be confused with a dot"
The line which triggered the error is as follows:
if ( myvar = .95 ){
How do I correct it?
Easy, put a zero before the dot. I guess JSLint complains because the dot is also used for object properties so it can be confused. Plus you're missing an equals, but in JS is recommended to use triple equals:
if (myvar === 0.95) { ... }
Now JSLint won't complain anymore.
That's not a real Javascript error. Javascript will work fine without the leading 0. However, to prevent JSLint from showing that error, just add the leading 0:
if ( myvar = 0.95 ){
It's clearer, but not actually necessary.
==
? The =
operator is for assignment, while the ==
operator is for comparison.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With