Here are some fun bits about JavaScript which you may enjoy as much as I did:
- NaN is a number which isn’t equal to any number. Not even to itself. Yep! So following statement will always return false.
>> NaN === NaN false
- == checks for equality. === checks for type of the operands too.
- “” is defined but it doesn’t have anything in it. Some thing which is not defined will have a value called undefined.
- JavaScript have two very interesting numbers: Infinity and -Infinity
>> typeof Infinity "number">> typeof -Infinity "number"
- Infinity – Infinity is not equal to 0. (Tell me about it!)
>> Infinity - Infinity NaN>> - Infinity + Infinity NaN
- Infinity * 0 is not equal to 0. Hmm!
>> Infinity * 0 NaN
- No, Infinity / 0 is not NaN.
>> Infinity / 0 Infinity
- null is the only primitive datatype that’s also considered an object sometimes.
- An octal number is represented by 0 in start of the number
>> var num = 0644; num; 420
- Hexadecimal number is represented by 0x in start of a number:
>> var num = 0x1A4; num; 420
- Exponents can be defined as:
>> var exponent = 42e+3; num; 42000
- Largest number JavaScript can handle is:
1.7976931348623157e+308
- So what will be 1e+309, you ask!
Infinity
- Smallest number JavaScript can handle is:
5e-324
Sources:
- Object-Oriented JavaScript by Stoyan Stefanov