@rbxts/jsnatives
Object.create
Creates a new object with the specified prototype object and properties.
Signature
function create<T>(obj?: T | undefined): T extends undefined ? {} : T & {}
Description
The Object.create()
method creates a new object, using an existing object as the prototype of the newly created object. If no prototype is specified, an empty object is created.
Examples
Creating an object with a prototype
const a = Object.create({a: 1});
print(a.a); // 1
Creating an object with a Proxy prototype
const a = Object.create(new Proxy({}, {get: (target, prop) => { return "none";}}));
print(a.a); // "none"
Creating an empty object
const a = Object.create();
print(a.a); // undefined