From 960c53c6200c920ff95c19368011b91378a216ce Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Tue, 22 Mar 2016 22:25:09 -0500 Subject: [PATCH] Add Accessing Arguments To A Function as a javascript til --- README.md | 3 +- .../accessing-arguments-to-a-function.md | 28 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 javascript/accessing-arguments-to-a-function.md diff --git a/README.md b/README.md index e449d19..903159a 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ variety of languages and technologies. These are things that don't really warrant a full blog post. These are mostly things I learn by pairing with smart people at [Hashrocket](http://hashrocket.com/). -_371 TILs and counting..._ +_372 TILs and counting..._ --- @@ -124,6 +124,7 @@ _371 TILs and counting..._ ### JavaScript +- [Accessing Arguments To A Function](javascript/accessing-arguments-to-a-function.md) - [Character Codes from Keyboard Listeners](javascript/character-codes-from-keyboard-listeners.md) - [Computed Property Names In ES6](javascript/computed-property-names-in-es6.md) - [Create An Array Containing 1 To N](javascript/create-an-array-containing-1-to-n.md) diff --git a/javascript/accessing-arguments-to-a-function.md b/javascript/accessing-arguments-to-a-function.md new file mode 100644 index 0000000..c74b829 --- /dev/null +++ b/javascript/accessing-arguments-to-a-function.md @@ -0,0 +1,28 @@ +# Accessing Arguments To A Function + +The `arguements` object is available within any JavaScript function. It is +an array-like object with all of the arguments to the function. Even if not +all of the arguments are referenced in the function signature, they can +still be accessed via the `arguments` object. + +```javascript +function argTest(one) { + console.log(one); + console.log(arguments); + console.log(arguments[1]); +} + +argTest(1); +// 1 +// [1] +// undefined + +argTest(1, 'two', true); +// 1 +// [1,'two',true] +// 'two' +``` + +See the [Arguments object +docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments) +on MDN for more details.