Javascript – know your method definitions

I definitely recommend regularly refreshing yourself on definitions of common methods used in Javascript, for example Array.prototype.filter() Consider this code: If I saw this code I would think that the author is probably mistaken about how filter works. In some cases array methods will mutate the original array, for example Array.prototype.sort(), but filter does not… Continue reading Javascript – know your method definitions

Published
Categorized as Javascript

Javascript – avoid nesting ifs

When writing conditional blocks of logic try to avoid nesting, for example, consider the below: This kind of nesting can make code hard to extend, hard to read and hard to debug, so we can move everything up to the top level like:

Published
Categorized as Javascript