Datatypes#
Here are the following common datatypes in JavaScript,
NumberStringBooleanSymbolObjectFunctionArrayDateRegExp
nullundefined
Numbers#
Since there are a single type of number there must be some compromises in the size. Numbers are initially a 32-bit integer but officially a 64-bit double precision float.
Math operations uses arithmetic operators as expected but there exist an object called
Maththat has methods likeMath.sinYou may parse
String, binary, hexadecimal, etc usingparseInt,parseFloat, or in generally you can use the unary operator+to parse to number. For instance,+ '0x10'; // 16
Operations with number may return
NaN(notnull) for cases that are notInfinityor-Infinity(which are other number types).
Strings#
Almost exactly like Java.
Boolean#
Uses the “truthy” and “falsy” concept that Python uses.