DEV Community

Discussion on: 5 things that might surprise a JavaScript beginner/ OO Developer

Collapse
 
softchris profile image
Chris Noring • Edited

I don't agree.. Try this code

const obj = {
  a: '1'
};

Object.freeze(obj)

obj.a = 2
console.log(obj.a);

You will see it outputs 1. I.e I'm unable to change the code... so I'm not sure what you are talking about to be honest? See MDN even developer.mozilla.org/en-US/docs/W...

Collapse
 
tilakmaddy_68 profile image
Tilak Madichetti

Oh yeah , My bad you're right

Acc to docs it says

freeze() returns the same object that was passed into the function

and not what I claimed it to be

Sorry for wasting your time, I was just drained for the day I guess.

Thread Thread
 
softchris profile image
Chris Noring

appreciate you trying to help to correct the article.. and taking the time reading it.

Some comments have been hidden by the post's author - find out more