Javascript
/
Fundamentals
- 1 Fundamentals 11
-
Hello World
-
Code structure
-
Use strict
-
Variables
-
Data types
-
Type conversions
-
Maths
-
Comparitions
-
Conditional
-
Loops
-
Functions
- 2 Testing 2
-
Mocha
-
Nested describe
- 3 Objects 4
-
Basics
-
Reference
-
Methods
-
Constructor
- 4 Types 5
-
Primitives
-
Numbers
-
Strings
-
Arrays
-
Json
- 5 Classes 3
-
Constructor
-
Binding
-
Inheritance
/
Data types
➟
➟
Last update: 12-01-2022
Types
There are eight basic data types in JavaScript.
/**
* The typeof operator returns the type of the argument.
* In javascript there is no char type, only string.
*/
console.log(typeof undefined); // undefined
console.log(typeof 0); // number
console.log(typeof 10n); // bigint
console.log(typeof true); // boolean
console.log(typeof "foo"); // string
console.log(typeof Symbol("id")) // symbol
console.log(typeof Math); // object
console.log(typeof alert); // function
Null
! Null is not an object, it a special type which represents nothing.
/**
* Null is a special data type which represents nothing.
*/
let a;
let b = null;
console.log(typeof a); // undefined
console.log(typeof b); // object
Backsticks
! Allows us to embed variables and extensions into a string.
/**
* With backsticks we can embed variables into strings.
*/
let s = "World";
console.log(`Hello, ${s}!`);
// Hello World!
console.log(`
The sum is:
${1 + 2}
` );
// The sum is:
// 3
➥ Questions github Fundamentals