There are 6 primative types in JavaScript.
stringnumberbigintbooleanundefinedsymbolnull is a special primative like type.
object is a more complex data structure.
BigInt is used to hold large integer values.
const a = 123456789012345n;
const b = BigInt(678967896789678678);
Boolean has two values true or false.
null means "nothing" or "empty".
var num = null;
Number in html is a 64-bit floating point number.
var x = 3.14;
There are three special numeric values for Numbers: Infinity, -Infinity, and Nan
An object in JavaScript is similar to a class in C++.
var person = {
firstName: "Dalton",
middleName: "Russell",
lastName: "Cole",
fullName: function() {
return `${firstName:} ${middleName:} ${lastName:}`;
}
}; // <- DON'T FORGET THE ;
There are three string quote options in JavaScript:
"Hello"'Hello'`Hello`Double and single quotes behave identically. Backticks allow code to be embedded into a string via ${...} wrapping.
var str = "Hello World";
var str2 = 'Hola Mundo';
var str3 = `English: ${str}, Spanish: ${str2}`
var str4 = `${1 + 2}`; // '3'
Escape sequences:
'\xA9''\u00A9' or '\uP00A9'undefined means "value is not assigned". Variables are undefined before they are assigned.
var num; // undefined