Is there a pure Javascript equivalent to jQuery's $.fn.extend? -


in jquery this:

$.fn.extend({    hello: function() {console.log(this + ' says hello world.')} }); 

and

$('div').hello(); 

can in pure javascript without loading whole jquery that?

well, technically this:

function extendingqueryselector(selector, extension) {     var el = document.queryselector(selector);     for(var key in extension) {         if(extension.hasownproperty(key)) {             el[key] = extension[key];         }     }     return el; } 

though doesn't seem idea extend basic dom objects. there's no jquery wrapper around here, though of course make such wrapper.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -