html
html
1
2
3
4
5
6
7
8
9
<!DOCTYPE html>
<html>
<head>
<title>Demo: Javascript Base Object Prototypes</title>
</head>
<body>
</body>
</html>
Enter to Rename, Shift+Enter to Preview
css
css
1
2
3
body {
}
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
const log = (...m) => {
console.log(m.join(" "))
}
const json = o => JSON.stringify(o, null, 3)
const a = {};
const b = {};
log("a and b are new objects.");
log(" a = {}");
log(" b = {}\n");
log("a and b are NOT the same objects:",
`${a != b}`);
log("a and b share the same prototype:",
`${a.__proto__ === b.__proto__}`);
log("a and {} share the same prototype:",
`${a.__proto__ === ({}).__proto__}`);
log("{} and {} are NOT the same objects:",
`${({}) != ({})}`);
log("{} and {} share base prototypes:",
`${({}).__proto__ === ({}).__proto__}\n`);
log("Array and {} share base prototypes:",
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run