Skip to content

Instantly share code, notes, and snippets.

@toddmantell
Created November 20, 2017 23:14
Show Gist options
  • Select an option

  • Save toddmantell/edb7aa96aefedc2a149810875c814fdf to your computer and use it in GitHub Desktop.

Select an option

Save toddmantell/edb7aa96aefedc2a149810875c814fdf to your computer and use it in GitHub Desktop.
Add function to Array.prototype
const numbers = [1,2,3,4,5,6,7,8];
Array.prototype.logValues = function() {
for (i = 0; i < this.length; i++) {
console.log(this[i]);
}
};
numbers.logValues();
const newArrayOfStuff = ['Todd', 67, true, 'Yo!', {id: '890435098435oui4587rteuoiert'}];
newArrayOfStuff.logValues();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment