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
Copy link

TeacherStijn commented Sep 17, 2020

Like! Thx 👍

Copy link

richyk1 commented Jul 8, 2021

Thanks for the quick snippet! Using it right now!

Copy link

nicojones commented Jul 19, 2021

Clever, thank you!

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