Javascript
/
Fundamentals
- 1 Fundamentals 11
-
Hello World S
-
Code structure S
-
Use strict S
-
Variables S
-
Data types S
-
Type conversions S
-
Maths S
-
Comparitions S
-
Conditional S
-
Loops S
-
Functions S
- 2 Testing 2
-
Mocha S
-
Nested describe S
- 3 Objects 4
-
Basics S
-
Reference S
-
Methods S
-
Constructor S
- 4 Types 5
-
Primitives S
-
Numbers S
-
Strings S
-
Arrays S
-
Json S
- 5 Classes 3
-
Constructor S
-
Binding S
-
Inheritance S
S
R
Q
Javascript Fundamentals Data Types
No char type, only string in Javascript null, special type representing nothing let s = "World" let b = null console.log(typeof b) // object
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
➥ Questions