html
html
1
2
3
4
5
6
7
8
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
</body>
</html>
Enter to Rename, Shift+Enter to Preview
css
css
1
Enter to Rename, Shift+Enter to Preview
js
js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//output to html instead of console
const disp = (x="",y="")=>document.write(`${x} <span style="color:red;font-weight:700;font-style:italic;margin-left:10px;">${y}</span><br>`);
const dspB = (x="")=>document.write(`<strong>${x}</strong><br>`);
let a = new Array();
dspB("let a = new Array();");
let b = {};
dspB("let b = {};");
//wrong ways: false
disp();
dspB("Wrong ways of checking(always returns false):")
disp("new Array()==a", (new Array()==a));
disp("b=={}", (b=={}));
disp("(new Array()==a)||(b=={})",
((new Array()==a)||(b=={})));
//true:
disp();
dspB("To check if var is Array:");
disp("Array.isArray(a)", Array.isArray(a));
disp("a isinstanceof Array",
(a instanceof Array));
disp("a.constructor===Array",
(a.constructor===Array));
disp("Object.prototype.toString.call(a)==='[object Array]'",
(Object.prototype.toString.call(a)==='[object Array]'));
disp("Array.prototype.isPrototypeOf(a)",
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run