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

ssh - Vagrant Windows - ssh_exchange_identification: read: Connection reset by peer -

gcc - Neither ld wrap nor LD_PRELOAD working to intercept system call -

maven - jacoco coverage per test setup -