javascript - Why is it a bad idea to override native methods? -


i posted question overriding push using object.defineproperty. original question here. code working on over my codepen.

a user left following comment:

it's bad idea overwrite native method, both on prototype or on instantiated objects

why?

the reason why decided override push because needed have push call method after element had been pushed. not changing functionality of push except have fire event on completion.

is bad did , if alternative?

one problem can think of have push method specific problem, , if later need normal push method. don't know if case or not, might cause have refactor code later, allow both "normal push" , "altered push".

another problem can think of, if , not 1 working on code, else might not know push overridden , not follow standard behaviour anymore.

this cause potential issues. might not have changed lot, in case changes made cause error, might leave else scratching head wondering why (in opinion normal) push causing odd behaviour.


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

unity3d - Fatal error- Monodevelop-Unity failed to start -