Skip to content

Instantly share code, notes, and snippets.

@artemhp
Created August 15, 2019 09:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save artemhp/9de1fc853460fe3bcb3b632c0299a39b to your computer and use it in GitHub Desktop.
Save artemhp/9de1fc853460fe3bcb3b632c0299a39b to your computer and use it in GitHub Desktop.
Create an instance of jQuery object
const arr = [];
const jQuery = function( selector, context ) {
return new jQuery.fn.init( selector, context );
}
jQuery.fn = jQuery.prototype = {version: 2};
jQuery.fn.init = function( selector, context, root ) {
this[ 0 ] = document.querySelector(selector);
return this;
}
jQuery.fn.init.prototype = {
constructor: jQuery,
push: arr.push,
pushStack: 2
};
console.log(jQuery('div'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment