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
Post a Comment