Previously I gave a brief introduction to closures in Javascript. Here I will attempt to provide more understanding on this topic. I will lead into the topic of closures by beginning with a look at an infamous problem with for loops in Javascript. I will also briefly touch on Immediately Invoked Function Expressions (IIFEs).
Month: January 2016
Returning in Javascript and Intoduction to Closures
Functions return a value of undefinded
by default, unless we explicitly tell it to return another value.
How do we do that?
Continue reading “Returning in Javascript and Intoduction to Closures”Study of a Function – titleCase()
Lets try and do a detailed analysis/deconstruction of a function titleCase()
which takes a string and capitalises the first letter of every word. It uses arrays and some string methods and demonstrates usage of the return keyword and the practice of passing one function as an argument to another.
Reconciling Return
The return keyword and its purpose is actually fairly simple but for some reason it seems to cause beginners a lot of confusion. Even after being exposed to it by example and explanation, it can take some time before understanding really sinks in. I know this was certainly the case for me but I don’t believe it needed to be that way. Lets see if we can’t help lessen that confusion here.