This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create our custom forEach function and attach it to the prototype | |
Array.prototype.customForEach = function(callback) { | |
const arr = this; | |
for(let i = 0; i < arr.length; i++) { | |
callback(arr[i], i, arr); | |
} | |
} | |
// Execute our custom forEach function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create our custom map function and attach it to the prototype | |
Array.prototype.customMap = function(callback) { | |
const arr = this; | |
const newArr = []; | |
for(let i = 0; i < arr.length; i++) { | |
const alteredElement = callback(arr[i], i, arr); | |
newArr.push(alteredElement); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create our custom filter function and attach it to the prototype | |
Array.prototype.customFilter = function(callback) { | |
const arr = this; | |
const newArr = []; | |
for(let i = 0; i < arr.length; i++) { | |
if (callback(arr[i], i, arr)) newArr.push(arr[i]); | |
} | |
return newArr; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create our custom reduce function and attach it to the prototype | |
Array.prototype.customReduce = function(callback, initialValue) { | |
let accumulator = initialValue; | |
let arr = this; | |
for(let i = 0; i < arr.length; i++) { | |
accumulator = (accumulator ? callback(accumulator, arr[i], i, arr) : arr[i]); | |
} | |
return accumulator; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create our custom some function and attach it to the prototype | |
Array.prototype.customSome = function(callback) { | |
const arr = this; | |
for(let i = 0; i < arr.length; i++) { | |
if(callback(arr[i], i, arr)) return true; | |
} | |
return false; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create our custom every function and attach it to the prototype | |
Array.prototype.customEvery = function(callback) { | |
const arr = this; | |
for(let i = 0; i < arr.length; i++) { | |
if (!callback(arr[i], i, arr)) return false; | |
} | |
return true; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create our custom find function and attach it to the prototype | |
Array.prototype.customFind = function(callback) { | |
const arr = this; | |
for (let i = 0; i < arr.length; i++) { | |
if (callback(arr[i], i, arr)) return arr[i]; | |
} | |
return false; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
// See http://babeljs.io/docs/en/env/ | |
{ | |
"presets": ["env", "react"] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path'); | |
const webpack = require('webpack'); | |
const BrowserSyncPlugin = require('browser-sync-webpack-plugin'); | |
module.exports = { | |
entry: './src/index.js', | |
mode: 'development', | |
module: { | |
rules: [ | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node_modules | |
dist |
OlderNewer