Loading lesson path
Concept visual
Start at both ends
A
8 types of data. 7 Primitive types or an Object type.
// Number let length = 16;
let weight = 7.5;
// BigInt let x = 1234567890123456789012345n;
let y = BigInt(1234567890123456789012345)
// Strings let color = "Yellow";
let lastName = "Johnson";
// Boolean let x = true;
let y = false;
// Undefined let x;
let y;
// Null let x = null;
let y = null;
// Symbol const x = Symbol();
const y = Symbol();A string (or a text string) is a series of characters like "John Doe". Strings are written with quotes. You can use single or double quotes:
// Using double quotes:
let carName1 = "Volvo XC60";// Using single quotes:
let carName2 = 'Volvo XC60';Try it Yourself » You can use quotes inside a string, as long as they don't match the quotes surrounding the string:
// Single quote inside double quotes:
let answer1 = "It's alright";// Single quotes inside double quotes:
let answer2 = "He is called 'Johnny'";// Double quotes inside single quotes:
let answer3 = 'He is called "Johnny"';Try it Yourself »
All JavaScript numbers are stored as decimal numbers (floating point). Numbers can be written with, or without decimals:
// With decimals:
let x1 = 34.00;// Without decimals:
let x2 = 34;Try it Yourself »
Extra large or extra small numbers can be written with scientific (exponential) notation:
let y = 123e5; // 12300000 let z = 123e-5; // 0.00123Try it Yourself »
Most programming languages have many number types:
byte
Formula
(8 - bit), short
(16 - bit), int
(32 - bit), long
(64 - bit)float
Formula
(32 - bit), double
(64 - bit).
Javascript numbers are always double (64 - bit floating point).Formula
All JavaScript numbers are stored in a 64 - bit floating - point format.JavaScript BigInt is a new datatype (
) that can be used to store integer values that are too big to be represented by a normal JavaScript Number.