> For the complete documentation index, see [llms.txt](https://racoon-js.gitbook.io/en/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://racoon-js.gitbook.io/en/api/array/default.md).

# default

default(value, \[strict=false], \[ctx])

## Effect

Set the return value of `validate` and `validateSilent` when the detected value is `undefined | null`.

If strict mode is turned o&#x6E;***(strict=true)***, set the return value when the detected value is `undefined | null | []`.

## Arguments

* `value` ***(\*)*** - The default return value of `validate` and `validateSilent`. It is recommended but not necessarily to be an array. When `value` is a function, then set the return value of `value` to be the default return value. *The function has a parameter: the original detected value - `undefined`, `null` or `[]`*.
* `[strict]` ***(boolean)*** - Whether turn on strict mode, default is `false`, means no-strict mode. You can exactly set `strict` to `true` to turn on strict mode.&#x20;
* `[ctx]` ***(\*)  -*** The execution context if `value` is a function.

> **ATTENTION**
>
> It is highly recommended to use a function to set the default return value, to avoid returning the same array when you call `validate` or `validateSilent` multiple times.

## Example

```javascript
const schema1 = racoon.array().default(
  () => [1]
);
schema1.validate(undefined); // pass, return: [1]
schema1.validate(null); // pass, return: [1]
schema1.validate([]); // pass, return: []

const schema2 = racoon().array().default(
  () => [1],
  true
);
schema2.validate(undefined); // pass, return: [1]
schema2.validate(null); // pass, return: [1]
schema2.validate([]); // pass, return: [1]
```
