-
-
Save artemhp/9de1fc853460fe3bcb3b632c0299a39b to your computer and use it in GitHub Desktop.
Create an instance of jQuery object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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