Skip to content

Commit

Permalink
Add apply and bind examples
Browse files Browse the repository at this point in the history
  • Loading branch information
igorcervac committed Dec 9, 2024
1 parent 3972d76 commit 2ee0245
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions array-foreach/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
const weekDays = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'];

console.log('Call');
Array.prototype.forEach.call(weekDays, function(d, i){
console.log(i+1, d);
});

console.log('Apply');
Array.prototype.forEach.apply(weekDays, [function(d, i){
console.log(i+1, d);
}]);

console.log('Bind');
Array.prototype.forEach.bind(weekDays)(function(d, i){
console.log(i+1, d);
});

0 comments on commit 2ee0245

Please sign in to comment.