According to the spec (Annex C), strict-mode code can’t do pretty much anything that might assign any identifier with the name eval. I can understand that one might want to restrict use of the actual eval function, but I don’t see what purpose is served by restricting use of the name?
According to the spec (Annex C), strict-mode code can’t do pretty much anything that
Share
I can only speculate, but it seems to me that ES5-strict is saying that
evalandargumentsshould be considered as raw syntax, not identifiers. It is reasonable that these two features should be implemented at the syntactical level, because they have Amazing Funky Magic behaviours that cannot be reproduced by a normal function.(In particular
evalmay write to local variables in the function that calls it, and writing toargumentsbizarrely changes the values of local variables corresponding to the arguments. Though this behaviour seems to be going away in strict mode, thankfully.)For compatibility reasons, ES5 can’t actually make
evalandargumentssyntactical. So they do the nearest they can, which is to say that the identifierargumentsalways refers toargumentsmagic and the identifierevalalways exclusively refers toevalmagic.It could also improve the possibilities for optimisation, if JS engines can be sure whether a function contains magic.