# Arrow functions in js
An arrow function in [[JavaScript|js]] is an abbreviated way to declare a function.
```js
test = function(input) {
return "You said" + input;
}
```
can be abbreviated as:
```js
test = (input) => "You said" + input;
```
[^w3schools]
You're now declaring a new [[Anonymous functions in js]] that takes the parameter `input` and processes it.
## In practice
```js
const options = {...}
options.forEach(option => {
console.log(option.file.link);
})
```
[^returnStudyOptions]
In the code above, the `option => {}` construction defines a function. Here's the full, expanded way to write the same bit of code:
```js
const options = {...}
options.forEach(
test = function (option) {
console.log(option.file.link);
}
)
```
[^returnStudyOptions]: From [this gist I made](https://gist.github.com/nicolevanderhoeven/eccc6f910cdc48a5b7934b53a5a0f244) about using [[Obsidian Dataview]] and [[Obsidian Templater]] to return activity options.
[^w3schools]: W3 Schools. _JavaScript Arrow Function_. Retrieved from https://www.w3schools.com/Js/js_arrow_function.asp