Created
January 2, 2017 09:25
-
-
Save steverydz/bf06ec69d57a0b4c5485e0ab9db1ec16 to your computer and use it in GitHub Desktop.
How to use function wrappers
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
// 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