Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
lurch3528yNaN is a String that gets returned when you console.log it. Try console.log($scope.edad.toString === 'NaN');. undefined works the same way.
-
tytho23168yTry {} == {}. Will always be false because they refer to different references. One NaN will never be equal to a different NaN. Instead use isNaN(variable)
-
tytho23168y@lurch I'm sure you could stringify an object for object comparison, but that could be a heavy operation depending on how big your objects are. It also would probably give you a lot of inconsistent behavior since object keys don't have a guaranteed order.
For example, you have an object { a: 1, b: 2 }, and another one { b: 2, a: 1 }. By our definition, they're "equal", but they would stringify as different strings. The NaN example would work for this if you're strictly checking to see if a number is NaN, but the correct way to do it would be to use the more predictable isNaN since you may run into an object that can't be coerced into a string. -
I'm pretty sure what you want is the isNaN function https://developer.mozilla.org/en-US... just one of those things you learn along the way.
-
@JoseHdez2 ah okay that makes sense. Tagalog has loan words from Spanish, and I guess edad is one of them. It age in Tagalog as well.
-
Griffal58yNaN is a number. If you wanna test it you should use Number.isNaN(NaN) //true
(console.log(typeof(NaN))//return 'number'
Why JS developers go bald sooner! ?#%*
undefined
pullshairoff