we (web engine): Experimental web browser project to understand the limits of Claude

JS Built-in: Object, Function, Array, Error #97

open opened by pierrelf.com

Implement the core built-in constructors and their prototype methods: Object, Function, Array, and Error.

Scope#

Object#

  • Object() constructor and Object.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]")
  • name and length properties

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 with message and stack properties
  • 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.

sign up or login to add to the discussion
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:meotu43t6usg4qdwzenk4s2t/sh.tangled.repo.issue/3mhn3mu7azr25