# JS syntax - functions
[[JS Syntax]]
## functions
global constant function
most of my DV code uses constants as functions
that may be against convention, idk, but it works
```js
const sum = (a,b) => {
return a+b
}
sum(1,2)
```
regular (?) function
```js
function sum(a,b) {
return a+b
}
```
you can also declare `async` functions which involve `await`ing something
### returning an array
```js
const getAB = () => {
let a = 4 +3
let b = 1 + 5
return [a,b]
}
```
getting the values back/restructuring the array:
this syntax hasn't worked for me yet
```js
var {aValue, bValue} = getAB()
```
so i get the values this way
```js
var abValues = getAB()
abValues[0] = 7
abValues[1] = 6
```