+ 2

about seal() ?

Object.seal(object) // Prevents changes of object properties (not values) what the meaning exactly ? it's different with freeze() but how it works ?

24th May 2020, 10:31 AM
Oneill~Онеилл~奥尼尔~ओनील~اونیل~*‎
Oneill~Онеилл~奥尼尔~ओनील~اونیل~*‎ - avatar
2 odpowiedzi
+ 1
As you say Object.seal prevents changing Object.properties not values .. Object.freeze is same with this issue but it prevents values too except Arrays and Objects their values are prevented but their values includes them can be changing Example: const obj = Object.freeze({ arr :[] }); obj.arr = ''; // impassable and TypeError in strict mode obj.arr.push('String'); // no problem here
24th May 2020, 11:45 AM
Basel.Al_hajeri?.MBH()
Basel.Al_hajeri?.MBH() - avatar
+ 1
thank for your answer
12th Jun 2020, 12:55 PM
Oneill~Онеилл~奥尼尔~ओनील~اونیل~*‎
Oneill~Онеилл~奥尼尔~ओनील~اونیل~*‎ - avatar