Last active
December 23, 2015 11:49
-
-
Save WebReflection/6631470 to your computer and use it in GitHub Desktop.
utils
This file contains hidden or 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
| var utils = (function (Object) { | |
| 'use strict'; | |
| var | |
| ObjectPrototype = Object.prototype, | |
| ArrayPrototype = Array.prototype, | |
| call = Object.call, | |
| utils = {}; | |
| function bind(name) { | |
| if (typeof this[name] === 'function') { | |
| utils[name] = call.bind(call, this[name]); | |
| } | |
| } | |
| utils.query = function query(CSS, parentNode) { | |
| return utils.slice( | |
| (parentNode || document).querySelectorAll(CSS) | |
| ); | |
| }; | |
| Object | |
| .getOwnPropertyNames(ArrayPrototype) | |
| .forEach(bind, ArrayPrototype); | |
| Object | |
| .getOwnPropertyNames(ObjectPrototype) | |
| .forEach(bind, ObjectPrototype); | |
| return utils; | |
| }(Object)); |
Author
Author
more examples …
utils.hasOwnProperty(object, key);
utils.toString([]); // [object Array]and similar stuff ..
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
some example …