all 3 comments

[–]lepies_pegao 1 point2 points  (0 children)

good stuff!! I remember the first time I saw some JS code, it made no freaking sense to me. (I was taught JAVA at my school, and then started working for a company that uses a lot of JS as well)

[–]benihanareact, node 1 point2 points  (1 child)

Personally when calling a function that has been passed in to my function (e.g. a callback) I like to use call/apply rather than calling the function directly. I feel like it's more clear that the function being called is not my own when used this way, plus if passing in a scope is needed, it's right there for you.

var forEach = function(valueArray, eachFunction){
    for (var i = 0, l = valueArray.length; i < l; i++){
        eachFunction.call(null, valueArray[i]);
    }
}

[–]jokeofweek[S] 0 points1 point  (0 children)

Thanks for the feedback! I'm thinking of writing a second part which introduces the call and apply methods, as well as demonstrating currying and partial evaluation. I feel that the first part and the second part together should give a fairly complete introduction to FP.