Skip to content
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

Running error ,when add array prototype methods #1326

Closed
ZhangGuangHuiCoder opened this issue Oct 9, 2024 · 1 comment · May be fixed by #1327
Closed

Running error ,when add array prototype methods #1326

ZhangGuangHuiCoder opened this issue Oct 9, 2024 · 1 comment · May be fixed by #1327
Labels

Comments

@ZhangGuangHuiCoder
Copy link

When add array prototype methods
image
image
image
image

@Fuzzyma
Copy link
Member

Fuzzyma commented Oct 9, 2024

Extending the prototype of buildin objects is frowned upon and shouldn't be done for exactly the reason you show here (any many more).

If you need extra methods on your array, extend the base array class and use your extended array:

class MyArray extends Array {
  get first() { return this[0] }
}

The error happens, because you created readonly properties on the array prototype.
I WANT to overwrite some array methods so I cant skip the ones that already exist.

So I am sorry, but this wont be fixed

@Fuzzyma Fuzzyma added the wontfix label Oct 9, 2024
@ZhangGuangHuiCoder ZhangGuangHuiCoder closed this as not planned Won't fix, can't repro, duplicate, stale Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants