HasOwnProperty and ECMAScript 5 strict mode

I am curious: does anyone know why the ECMAScript5 specification did not drag out more of the predefined object prototype properties in strict mode? For example, there seems to be no information regarding the method for determining hasOwnProperty. I tried overriding it (and tested the code in FF4 beta) and I managed to avoid it. If I havenโ€™t done anything wrong, then this means that everyone can override the Object.prototype.hasOwnProperty property and really screw all the code that relies on it for the property to work ...

thoughts about that?

EDIT: A bit more info as I dig into the spec ...

As I added a comment below, you cannot really change Object.prototype in strict mode because of the metadata that was applied to it (Writable, Enumerable and Configurable are set to false) and FF 4 beta (which I use to run my tests ) throws an exception.

thank.

+3
source share
1 answer

AND? I can kill everything on Object.prototype, if I want, do not include such code in my project / site, do not do something better, find those idiots who do such things, and make sure they play balls.

I mean, I can even ruin any given Python program (2.x) by running True = False.

You can never protect against idiots. Never. Try to educate or avoid them.

EDIT

, script ( , ), "use strict" .

, - ... , , ES3, .

+3

Source: https://habr.com/ru/post/1784538/


All Articles