Last active
August 29, 2015 14:06
-
-
Save seriousManual/a13ea8cf3df4af91d9e0 to your computer and use it in GitHub Desktop.
inline arguments via sweet js
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
macro inlineArgs { | |
rule {} => { | |
(function(outerArguments) { | |
var argsArray = []; | |
for (var i = 0; i < outerArguments.length; i++) { | |
argsArray.push(outerArguments[i]); | |
} | |
return argsArray; | |
})(arguments) | |
} | |
} |
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
function fooBar() { | |
var myArgs = function (outerArguments) { | |
var argsArray = []; | |
for (var i = 0; i < outerArguments.length; i++) { | |
argsArray.push(outerArguments[i]); | |
} | |
return argsArray; | |
}(arguments); | |
console.log(myArgs); | |
} |
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
function fooBar() { | |
var myArgs = inlineArgs; | |
console.log(myArgs); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment