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:
javascriptlet date = new Date;
If we output the date object to the console, we will see its string representation:
javascriptconsole.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:
javascriptconsole.dir(date);
Задание 1
Examine the output of the following code:
javascriptlet reg = new RegExp;
console.log(reg);
console.dir(reg);
console.log(reg instanceof RegExp);
Задание 2
Examine the output of the following code:
javascriptlet arr = [1, 2, 3];
console.log(arr);
console.dir(arr);
console.log(arr instanceof Array);
Задание 3
Examine the output of the following code:
javascriptlet arr = new Array(1, 2, 3);
console.log(arr);
console.dir(arr);
console.log(arr instanceof Array);
Задание 4
Examine the output of the following code:
javascriptlet obj = {a: 1, b: 2, c: 3};
console.log(obj);
console.dir(obj);
console.log(obj instanceof Object);
Задание 5
Examine the output of the following code:
javascriptlet obj = new Object;
console.log(obj);
console.dir(obj);
console.log(obj instanceof Object);