I am following some tutorials and I came up with the following code, I am unable to understand how is it working behind the scene. Anyone can please explain how is it actually working.
So here I made a function mapForEach.
const arr1 = [1, 2, 3]
const mapForEach = (arr, fn) => {
let newArr = []
for (let i = 0; i < arr.length; i++) {
newArr.push(
fn(arr[i])
)
}
return newArr;
}
Now here I made other two Functions CheckPastLimit and CheckPastLimitSpecified. Now here checkPastList check for the condition. All good to this point.
const CheckPastLimit = (limiter, item) => {
return item > limiter
}
Now here CheckPastLimit is used as a parameter and arr2 return value that pass CheckPastLimit condition (item > limiter). So I want to know how is this line working exactly? How is this line working behind the scene?
const arr2 = mapForEach(arr1, CheckPastLimit.bind(this, 1))
console.log(arr2)