Built-in JavaScript classes
JavaScript has many built-in classes that you've encountered before. Let's look at working with dates as an example:
let date = new Date;
If we output the date object to the console, we will see its string representation:
console.log(date);
You can, however, see a list of the object's properties and methods in the console. To do this, use the following command:
console.dir(date);
Examine the output of the following code:
let reg = new RegExp;
console.log(reg);
console.dir(reg);
console.log(reg instanceof RegExp);
Examine the output of the following code:
let arr = [1, 2, 3];
console.log(arr);
console.dir(arr);
console.log(arr instanceof Array);
Examine the output of the following code:
let arr = new Array(1, 2, 3);
console.log(arr);
console.dir(arr);
console.log(arr instanceof Array);
Examine the output of the following code:
let obj = {a: 1, b: 2, c: 3};
console.log(obj);
console.dir(obj);
console.log(obj instanceof Object);
Examine the output of the following code:
let obj = new Object;
console.log(obj);
console.dir(obj);
console.log(obj instanceof Object);