Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Attach event listener to Array push method call
var eventify = function(arr, callback) {
arr.push = function(e) {, e);
var array = [1,2,3];
eventify(array, function(newArray) {
alert("new array length is:" + newArray.length);
array.push(4); // alerts new array length is: 4
array.push(5); // alerts new array length is: 5

This comment has been minimized.

Copy link

@TeacherStijn TeacherStijn commented Sep 17, 2020

Like! Thx 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment