All about Values in JavaScript

Inside of a computer there is only bits (0 or 1), an ocean of bits. And every data stored in it (numbers, texts or anything else) will be converted to a set of bits.

Storing a value

To store a specific value in memory using JavaScript, we use Variables in form of name value peers, so we can call this value by it assigned name only.

Exemples:

// Simple global variable:
var name = ‘Badr’;

// Simple scoop variable:
let name = ‘Badr’;

// Simple scoop constant (variable that never change it’s value):
const name = ‘Badr’;

Types of values

In JavaScript, we use numbers, texts, booleans, and empty values (don’t worry about last one we will talk about it).

Numbers

Value of type Number is a numeric value, and we can store both positive and negative numbers.

Exemples:

// Positive number
let positiveNumber = 2020;

// Negative number
let negativeNumber = -2020;

And also, we can store fractional numbers using dot, and for very big or small fractional numbers we can use scientific notation by
adding an e (for exponent).

Exemples:

// Simple fractional number:
let fractionalNumber = 2020.543;

// Fractional number with scientific notation:
let scientificNotation = 2020.54e6

Arithmetic operations