document functino nr args
This commit is contained in:
@@ -22,6 +22,7 @@ All code uses 2 spaces for indentation. K&R style for C and Javascript.
|
||||
- No classes — only objects and prototypes (`meme()`, `proto()`, `isa()`)
|
||||
- No `for...in`, `for...of`, spread (`...`), rest params, or default params
|
||||
- No named function declarations — use `var fn = function() {}` or arrow functions
|
||||
- Functions have a maximum of 4 parameters — use a record for more
|
||||
- Variables must be declared at function body level only (not in if/while/for/blocks)
|
||||
- All variables must be initialized at declaration (`var x` alone is an error; use `var x = null`)
|
||||
- No `try`/`catch`/`throw` — use `disrupt`/`disruption`
|
||||
|
||||
@@ -398,6 +398,8 @@ fn2() // 1
|
||||
|
||||
### Arguments
|
||||
|
||||
Functions can have at most **4 parameters**. Use a record to pass more values.
|
||||
|
||||
Extra arguments are ignored. Missing arguments are `null`.
|
||||
|
||||
```javascript
|
||||
@@ -406,6 +408,11 @@ fn(1, 2, 3) // 3 (extra arg ignored)
|
||||
|
||||
var fn2 = function(a, b) { return a }
|
||||
fn2(1) // 1 (b is null)
|
||||
|
||||
// More than 4 parameters — use a record
|
||||
var draw = function(shape, opts) {
|
||||
// opts.x, opts.y, opts.color, ...
|
||||
}
|
||||
```
|
||||
|
||||
### Immediately Invoked Function Expression
|
||||
|
||||
Reference in New Issue
Block a user