jquery source code snippets are as follows:
// HANDLE: $(expr, $(...))
} else if ( !context || context.jquery ) {
return ( context || rootjQuery ).find( selector );
I think context here is a jquery object, rootjquery is $(document)
But shouldn’t the demerit they return be a Boolean value? Why is it a jquery object here?
So what does the || operation do here? What is its role???
Thanks
Please see here for the basics, which is clear at a glance.
https://developer.mozilla.org...
One more thing, before ES2015, JS functions did not have default parameters.
In order to use default parameters like other languages, they were often written like this
In order to be compatible with different browser APIs, we often write like this.
Javascript logical operators can be used in non-Boolean environments.
(from logical operator)
For non-Boolean environments:
(derived from the return value of logical operations in JavaScript (logical AND &&, logical OR ||, logical NOT!))