The example you showed,
.toNum()
is not a part of jQuery. It's an example of adding a function to
the String object in a StackOverflow post. It is not
"chainable" in the sense that jQuery objects are. It has
nothing at all to do with jQuery, in fact. You can "chain" it
with other String functions, because it is a String object function. It
is applied to a String object and returns a String object, and so you
can chain it with other String functions.
jQuery.isNumeric()
takes any value and return a simple boolean value. There's no
suitable object to hang it on and make it "chainable".
There isn't any Boolean object. You can't make it a String
function. A boolean is not a String.
jQuery.trim()
could potentially be "chainable". But then it
would have to be a String function, (String.fn.trim()).
I presume jQuery doesn't want to make the precedent of
polluting a standard DOM object. jQuery is meant to be confined
to the single jQuery object.
Modifying built-in objects is often called
"monkey-patching". jQuery doesn't monkey-patch.
Developers have different opinions about monkey-patching, but I
think most would agree that for a library to monkey-patch would
potentially lead to some unwanted monkey-businesses!
That is: monkey-patching
in your own code: OK, if you can stand the smell.
monkey-patching in a library: bad library!
I think it's OK for a single-purpose library or script to
monkey-patch. For example, there are several very useful scripts
that replace console with an
alternative.