// TODO: Create method objectFreeze which works the same as native Object.freeze. // !IMPORTANT: You haven't use Object.freeze during your task function objectFreeze(obj) { if (typeof obj !== 'object' || Array.isArray(obj)) { return obj } [ ...Object.getOwnPropertyNames(obj), ...Object.getOwnPropertySymbols(obj), ].forEach(key => { const des = Object.getOwnPropertyDescriptor(obj, key) if (!des.get || !des.set) { Object.defineProperty(obj, key, { configurable: false, writable: false, }) } }) return obj }
- // TODO: Create method objectFreeze which works the same as native Object.freeze.
- // !IMPORTANT: You haven't use Object.freeze during your task
- function objectFreeze(obj) {
return Object.freeze(obj);- if (typeof obj !== 'object' || Array.isArray(obj)) {
- return obj
- }
- [
- ...Object.getOwnPropertyNames(obj),
- ...Object.getOwnPropertySymbols(obj),
- ].forEach(key => {
- const des = Object.getOwnPropertyDescriptor(obj, key)
- if (!des.get || !des.set) {
- Object.defineProperty(obj, key, {
- configurable: false,
- writable: false,
- })
- }
- })
- return obj
- }