1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 18:58:12 +00:00

LibJS: Add a global "Object" constructor

This patch adds an "Object" constructor to the global object. The only
function it implements so far is Object.getPrototypeOf().
This commit is contained in:
Andreas Kling 2020-03-28 17:23:54 +01:00
parent a3d92b1210
commit 14047ca432
9 changed files with 134 additions and 3 deletions

View file

@ -0,0 +1,11 @@
function assert(x) { if (!x) throw 1; }
try {
var o1 = new Object();
var o2 = {};
assert(Object.getPrototypeOf(o1) === Object.getPrototypeOf(o2));
assert(Object.getPrototypeOf(Object.getPrototypeOf(o1)) === null);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}

View file

@ -0,0 +1,10 @@
function assert(x) { if (!x) throw 1; }
try {
var o = new Object();
Object.prototype.foo = 123;
assert(o.foo === 123);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}