New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extending Array does not work correctly #571
Comments
Try in traceur repl |
I don't believe Natives can be subclassed yet, unfortunately this is a platform limitation. In theory some hacks could exist to pseudo implement 1 level of inheritance by fetching the native from another realm and mutating it, but this really is a slippery slope. |
class FooArray extends Array {
constructor(a) {
super(a);
}
}
var e = new FooArray();
e.push('bar');
console.log(e);
console.log(e.length);
console.log(e instanceof Array);
console.log(Array.isArray(e)) traceur: |
Duplicate? #570 |
See Caveats |
Leaving this here for anyone Googling this error message: subclass_string.jsclass MyString extends String {
constructor (value) {
super(value)
}
}
let test = new MyString('foo');
test += 'bar';
console.log(test); result
|
Hi, I just tried to extend Array in your playground, and tested it then again in an traceur playground
6to5: {"0":"bar","length":1}
tracur: ["bar"]
The text was updated successfully, but these errors were encountered: