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

preventExtensions 与freeze、seal区别 #169

Open
TieMuZhen opened this issue Apr 17, 2022 · 0 comments
Open

preventExtensions 与freeze、seal区别 #169

TieMuZhen opened this issue Apr 17, 2022 · 0 comments

Comments

@TieMuZhen
Copy link
Owner

const obj = {
    a: 1,
    b: 2
}
Object.preventExtensions(obj);
obj.a = 2; // 可修改
delete obj.b; // 可删除
obj.c = 3; // 不可拓展

console.log(obj);

image

preventExtensions、freeze、seal区别

freeze:不可修改、不可删除、不可拓展
seal:可修改、不可删除、不可拓展
preventExtensions:可修改、可删除、不可拓展

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

No branches or pull requests

1 participant