1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-03 15:18:01 +00:00

Add Accessing Arguments To A Function as a javascript til

This commit is contained in:
jbranchaud
2016-03-22 22:25:09 -05:00
parent 384e75b4c2
commit 960c53c620
2 changed files with 30 additions and 1 deletions

View File

@@ -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.