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

给Array原型扩展方法建议使用Object.defineProperty #1

Open
2van opened this issue Jan 7, 2019 · 1 comment
Open

给Array原型扩展方法建议使用Object.defineProperty #1

2van opened this issue Jan 7, 2019 · 1 comment

Comments

@2van
Copy link
Contributor

2van commented Jan 7, 2019

  • 直接使用Array.prototype会导致他人代码可能会出问题,比如在for(i in list){console.log(i)} 会输出扩展方法的key,导致之前有数组使用for in方法的地方全部需要改为forEach。
  • 给Array原型扩展方法建议使用Object.defineProperty,此方法添加的属性可枚举性默认为false。
@k8w
Copy link
Owner

k8w commented Jan 7, 2019

求PR啊~~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants