We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
第358天 举例说明Object.defineProperty会在什么情况下造成循环引用导致栈溢出?
我也要出题
The text was updated successfully, but these errors were encountered:
var data = { count: 1, value: 2 } Object.defineProperty(data, 'count', { enumerable: true, configurable: true, get: function () { console.log('你访问了count', this.count); // 循环读取data.count 导致报错 return this.value }, set: function (newVal) { console.log('你设置了count'); } }) console.log(data.count) // 报错 Maximum call stack size exceeded
Sorry, something went wrong.
var person = { age:1 } Object.defineProperty(person,'age',{ get(){ return this.age }, set(val){ this.age = val } }) person.age 报错:Maximum call stack size exceeded,循环引用导致栈溢出 person.age --> get.call(person) -->this.age --> person.age --> get.call(person) --> this.age --> .......
No branches or pull requests
第358天 举例说明Object.defineProperty会在什么情况下造成循环引用导致栈溢出?
我也要出题
The text was updated successfully, but these errors were encountered: