1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-02 22:58:01 +00:00

Add Truthiness of Integer Arrays as a javascript til.

This commit is contained in:
jbranchaud
2015-05-08 08:20:05 -05:00
parent a528d891f7
commit 1bf6290c2a
2 changed files with 29 additions and 0 deletions

View File

@@ -38,6 +38,7 @@ smart people at [Hashrocket](http://hashrocket.com/).
## javascript
- [Character Codes from Keyboard Listeners](javascript/character-codes-from-keyboard-listeners.md)
- [Truthiness of Integer Arrays](javascript/truthiness-of-integer-arrays.md)
### postgres

View File

@@ -0,0 +1,28 @@
# Truthiness of Integer Arrays
We can consider the truthiness of `[1]` as follows:
```javascript
> [1] == true
=> true
> Boolean(true)
=> true
> Boolean([1])
=> true
```
We can consider the truthiness of `[0]` as follows:
```javascript
> [0] == false
=> true
> Boolean(false)
=> false
> Boolean([0])
=> true
```
The truthiness of `[0]` does not seem to be consistent.
See this [JavaScript Equality Table](https://dorey.github.io/JavaScript-Equality-Table/)
for more details.