I was working with a javascript API and I saw this quote:
Because JavaScript is a scripting language, every line of code takes up valuable processor time. On
Chaining methods like this CAN improve performance, but only in limited scenarios where the API you're using is built to provide this functionality. The first example that comes to mind is with jQuery.
Calling $("#test") takes time to return the jquery object that references #test.
When you chain a method, it reuses that object.
Check out this test I made as an example.
http://jsperf.com/chaining-demo