This commit is contained in:
Rico Sta. Cruz 2017-03-07 16:51:40 +08:00
parent b8b48d5e44
commit 22a3fa5262
No known key found for this signature in database
GPG Key ID: CAAD38AE2962619A
1 changed files with 2 additions and 2 deletions

View File

@ -10,9 +10,9 @@ category: JavaScript
| Number to string | `'' + num` | `num.toString()` |
| Date to UNIX timestamp | `+new Date()` | `new Date().getTime()` |
| Any to boolean | `!!value` | `Boolean(value)` |
| Check array contents | `if (~arr.indexOf(v))` | `if (arr.contains(v))` \* |
| Check array contents | `if (~arr.indexOf(v))` | `if (arr.includes(v))` |
> * = `.contains` is ES6-only, otherwise use `.indexOf(val) !== -1`
> `.includes` is ES6-only, otherwise use `.indexOf(val) !== -1` if you don't polyfill
## Examples