Some checks failed
ci / fast (linux) (push) Failing after 13m32s
Implements full class support: prototype-chain-based inheritance on JsObject, class/extends/super/static/instanceof keywords, parser and VM execution for class declarations and expressions, super() constructor calls and super.method() dispatch via dedicated SuperInfo fields (not user-observable properties), and instanceof operator with prototype chain walking. Includes depth guards, Box<JsValue> in RuntimeError::Thrown to satisfy clippy result_large_err, and 11 JS262 conformance tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
24 lines
440 B
JavaScript
24 lines
440 B
JavaScript
// Class inheritance with extends and super() call.
|
|
class Animal {
|
|
constructor(name) {
|
|
this.name = name;
|
|
}
|
|
speak() {
|
|
return this.name;
|
|
}
|
|
}
|
|
|
|
class Dog extends Animal {
|
|
constructor(name, breed) {
|
|
super(name);
|
|
this.breed = breed;
|
|
}
|
|
info() {
|
|
return this.name + ' is a ' + this.breed;
|
|
}
|
|
}
|
|
|
|
var d = new Dog('Rex', 'Labrador');
|
|
console.log(d.info());
|
|
console.log(d.speak());
|