26. Number
[ digits ][ .digits ][ ( E | e ) [ ( + | - ) ] digits ]
x=0 x = -077
x = 123 x = NaN
x = -14 x = Number.MAX_VALUE = 1.7976931348623157e+308
x = 0.1541 x = Number.MIN_VALUE = 5e-324
x = NaN x = Number.NEGATIVE_INFINITY
x = 0x1123 x = Number.POSITIVE_INFINITY
x = -0xF1A7 x = Number.NaN
x = 015
Some techniques break JSLint rulesOthers look bizarre or daftFine when you’re coding by yourselfRequire good reasons and good explanatory comments in a team environment
Plenty of tools availableSome even in the browsers
Doing it wrongTime from beginning to endDoing it rightCount number of iterations
There is an overhead to looping
Variation on Duff’s deviceIf we know we have a number of iterations that is a 32 bit number, we can dump the parseInt too
Dynamically typedDifference between equal and strict equal
Equal only compares valuesStrict equal compares values AND type
Returns one of two values based on the logical value of the condition
Perform functions on values as binary numbersTreat operands as a set of 32 bitsReturn standard numerical values
Technically a 64-bit number; actually 32-bit when doing anything bitwise.
Invisible functions
Converts to an integerConverts to a signed 32-bit integerConverts to an unsigned 32-bit integerConverts to an unsigned 16-bit integer
Allows multiple expressions to be evaluated in a single statementReturns the result of the last expression
Returns expr1 if it can be converted to true; otherwise, returns expr2.
Returns expr1 if it can be converted to false; otherwise, returns expr2.