javascript - Calling original method when overriding array push -


i'm attempting override push on array. need able call original push method before overriding can push element onto array.

below code. i've added list.push within value method. know wrong, added show trying do.

let list = [   'one',   'two',   'three' ]  object.defineproperty(list, 'push', {   value: function(el) {     list.push(el) // know wrong. example of trying do.    } }) 

invoke original prototype implementation current object context:

array.prototype.push.call(this, el) 

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 -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -