Numerical data
come in two forms:
❑ Whole numbers, such as 145, which are also known as integers. These numbers can be positive
or negative and can span a very wide range in JavaScript: –2^53 to 2^53.
❑ Fractional numbers, such as 1.234, which are also known as floating-point numbers. Like integers,
they can be positive or negative, and they also have a massive range.
In simple terms, unless you’re writing specialized scientific applications, you’re not going to face problems
with the size of numbers available in JavaScript.
Also, although you can treat integers and floating-point differently when it comes to storing them, JavaScript actually treats them both as floating-
point numbers. It kindly hides the detail from you so you generally don’t need to worry about it. One exception is when you want an integer but you have a floating-point number, in which case you’ll round the number to make it an integer.
Text data
“Hello World” and “A” are examples of strings that JavaScript will recognize.
You can also use the single quote marks (‘), ‘Hello World’ and ‘A’ are also examples of strings that JavaScript will recognize.
A double quote inside a string enclosed in double quotes? Well, everything just said about the single quote still applies. So ‘Hello “Paul”’ works, but “Hello “Paul”” won’t.
However, “Hello \”Paul\”” will also work.
Variables
Are case sensitive
One common method is Hungarian notation, where the beginning of each variable name is a three-letter identifier indicating the data type. For
example, you may start integer variable names with int, floating-point variable names with flt, string variable names with str, and so on.
Whenever JavaScript detects
that the contents of a variable are no longer usable, such as when you allocate a new value, it performs
the garbage collection process and makes the memory available. Without this automatic garbage collec-
tion process, more and more of the computer’s memory would be consumed, until eventually the com-
puter would run out and the system would grind to a halt. However, garbage collection is not always as efficient as it should be and may not occur until another page is loaded.