step1 : Object.defineProperty(this, "MAX_SIZE", { value: 100 }); // setting a new property to window object(this refers to window object). and its not writable through assignment. you can change this value.
step2 : MAX_SIZE = 200;
with out var keyword all the variables are belongs to window object , here we are trying to change the property of the window object which we created in first step and its not possible.
100 both the times because of hoisting?
ReplyDeleteCan you please explain further Praveen?
Deletestep1 : Object.defineProperty(this, "MAX_SIZE", {
ReplyDeletevalue: 100
}); // setting a new property to window object(this refers to window object). and its not writable through assignment. you can change this value.
step2 : MAX_SIZE = 200;
with out var keyword all the variables are belongs to window object , here we are trying to change the property of the window object which we created in first step and its not possible.
so both times it will be same.
sorry typo "its not writable through assignment. you can not change this value.)
Delete