4 ms·
That's true, but I was looking for a solution that could not be tricked by defining a variable on the client side. I know the probability of someone using that
by etler 14y ago
That's true, but I was looking for a solution that could not be tricked by defining a variable on the client side. I know the probability of someone using that particular variable is low, but my proposed solution is fool proof and also simple.
- TimothyFitz 14y agomodule = NaN will cause your script to be tricked, because NaN !== NaN. Not sure how to fix it, because isNaN can be overridden.
- etler 14y agoAhh, that's clever. Overall I just don't want to tell people what variable names to use, even if they are obscure. At the very least the end developer can use the variable names for everything else other than NaN.
- riquito 14y agoYou can check yourself if a value is NaN // NaN typeof is ... number typeof value === 'number' && value != value btw, the original isNaN() doesn't check if a value is NaN, it checks if a value is coercible to a number > isNaN("hello world") true