JavaScript Method Chaining… It’s All So STUPID!

Jason Knight
CodeX
Published in
9 min readAug 21, 2021

--

For some time we’ve seen the rise of chaining methods and responses together. jQuery started the trend, and now with things like promises it’s risen to new heights of popularity… but to be brutally frank, it’s all such mind-numbingly overcomplicated nonsense!

Garbage that’s only further compromised code clarity and increased overhead thanks to making damned near everything “callback’ driven. Callbacks introduce overhead just in terms of their being functions, particularly when used inside a loop. Worse if they’re anonymous functions — even arrow driven — they’re reparsed on every usage!

Take this article here:

Good writing style, excellent overview of how it works, and I hate to rip this guy to shreds… but what it’s doing is really REALLY dumb because of how bloated, slow, and inefficient the resultant code is.

He’s got this:

const csStudents = students.filter(student => student.class === 'CS')
.map(student => student.email)
.forEach(email => sendInvitation(email));

--

--

Jason Knight
CodeX

Accessibility and Efficiency Consultant, Web Developer, Musician, and just general pain in the arse