Skip to content

Instantly share code, notes, and snippets.

@steverydz
Created January 2, 2017 09:25
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 steverydz/bf06ec69d57a0b4c5485e0ab9db1ec16 to your computer and use it in GitHub Desktop.
Save steverydz/bf06ec69d57a0b4c5485e0ab9db1ec16 to your computer and use it in GitHub Desktop.
How to use function wrappers
// When wrapping a function, such as console.log for example,
// you should use the implicit arguments object rather than
// passing in your own parameters.
// Examples:
// Bad
var logWrapper = function (message) {
console.log(message);
};
// Good
var logWrapper = function () {
console.log.apply(null, arguments);
};
// or
function logWrapper() {
console.log.apply(null, arguments);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment