Implement the core built-in constructors and their prototype methods: Object, Function, Array, and Error.
Scope#
Object#
Object()constructor andObject.create(proto, props)Object.keys(),Object.values(),Object.entries()Object.assign(target, ...sources)Object.defineProperty(),Object.defineProperties()Object.getOwnPropertyDescriptor(),Object.getOwnPropertyNames()Object.getPrototypeOf(),Object.setPrototypeOf()Object.freeze(),Object.seal(),Object.isFrozen(),Object.isSealed()Object.is()Object.prototype.hasOwnProperty(),Object.prototype.toString(),Object.prototype.valueOf()
Function#
Function()constructor (basic — can defer full eval)Function.prototype.call(thisArg, ...args)Function.prototype.apply(thisArg, argsArray)Function.prototype.bind(thisArg, ...args)Function.prototype.toString()(return source or "[native code]")nameandlengthproperties
Array#
Array()constructor,Array.isArray(),Array.from(),Array.of()- Mutating:
push,pop,shift,unshift,splice,sort,reverse,fill,copyWithin - Non-mutating:
concat,slice,join,flat,flatMap - Iteration:
forEach,map,filter,reduce,reduceRight,find,findIndex,some,every - Search:
indexOf,lastIndexOf,includes - Array length property (auto-updating)
- Sparse array support (basic)
Error#
Error(message)constructor withmessageandstackproperties- Subclasses:
TypeError,ReferenceError,SyntaxError,RangeError,URIError,EvalError Error.prototype.toString()— "ErrorType: message"- Stack trace capture on construction
Acceptance Criteria#
- Object static methods and prototype methods work correctly
- Function.prototype.call/apply/bind work
- Array methods produce correct results (test each category)
- Array length updates on mutation
- Error types construct with message and stack
- Error subclasses have correct prototype chain
- Unit tests for each built-in method
Phase 10 — JavaScript Engine (issue 8 of 15). Depends on: JS Functions/closures/scoping.