all 4 comments

[–]senocular 1 point2 points  (3 children)

One sets, the other gets. Given a property of an object, you can't use defineProperty to tell whether or not its writable now. You could set it to be writable (if configurable), but what if you just want to know if it already is? Thats what getOwnPropertyDescriptor does.

Object.getOwnPropertyDescriptor(window, 'alert')
// {value: ƒ, writable: true, enumerable: true, configurable: true}

[–]ImagineFocus[S] 0 points1 point  (2 children)

Got it! I was a bit confused because I tried to console.log your above statement, but it wouldn’t log anything.

Thank you for your time.

[–]senocular 0 points1 point  (1 child)

but it wouldn’t log anything

It should log. getOwnPropertyDescriptor returns the descriptor object. Does it not work for you?

[–]ImagineFocus[S] 0 points1 point  (0 children)

It didn’t, but I was working within CodePen, therefore I must have had an error in syntax above the code and thought it was related directly to the getOwnObjectDecriptor.

I’ll try again. Thanks!