JavaScriptPatterns
JavaScriptPatterns copied to clipboard
Place of return statement in a jQuery plugin in code snippet | Chapter 8 Web Patterns
On p. 178 your book provides an example of a jQuery plugin like this:
$.fn.yeller = function () {
this.each(function (_, item) {
$(item).val($(item).val().toUpperCase());
return this;
});
}
Shouldn't it actually return this
only once after the loop (instead of every iteration) or, better yet, return this.each()
, as in the documentation.