Last active
November 18, 2017 00:07
-
-
Save ericelliott/bde5fcaf74abf26b9039 to your computer and use it in GitHub Desktop.
classy jQuery - an alternate reality where jQuery really sucked and never took off
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
/** | |
classy jQuery - an alternate reality where jQuery really sucked and never took off | |
OR | |
Why nobody would have liked jQuery if it had exported a class instead of a factory. | |
**/ | |
// This just looks stupid. Are we creating a new DOM element | |
// with id="foo"? Nope. We're selecting an existing DOM element | |
// with id="foo", and wrapping it in a jQuery object instance. | |
var $foo = new $('#foo'); | |
// Besides, it's a lot of extra typing with literally ZERO gain. | |
var $bar = new $('.bar'); | |
var $baz = new $('.baz'); | |
// And this is just... well. I don't know what. | |
var $bif = new $('.foo').on('click', function () { | |
var $this = new $(this); | |
$this.html('clicked!'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment