- 追加された行はこの色です。
- 削除された行はこの色です。
* 型 [#p5f2886c]
* 型 [#jef8827a]
** 型一覧 [#jb361f3c]
- string
- number
- boolean
- null
- undefined
- Object
-- function
-- Array
-- Date
-- RegExp
#lsx
** 型を調べる [#k7068d01]
if (typeof(foo) =="boolean" ) {
...
}
*** typeof演算子の返す値 [#z50b9a8e]
- string
- number
- boolean
- function
- object
- undefined
typeof [1, 2, 3] // => "object"
typeof parseInt("a") // => "number"
*** instanceof演算子の挙動 [#b4791a98]
var obj = {};
var arr = [];
obj instanceof Object // => true
obj instanceof Array // => false
arr instanceof Object // => true
arr instanceof Array // => true
** 条件式での評価 [#r1377173]
以下の場合は偽で評価される。それ以外は真で評価される。
- false
- 0
- ""
- NaN
- undefiled
- null
** キャスト [#w8f25cd8]
*** Number [#q2230833]
+'10' == 10
*** String [#g4e18c29]
'' + 10 == '10'
*** Boolean [#ac7b603b]
!!'foo'; // => true
!!''; // => false
!!'0'; // => true
!!'1'; // => true
!!'-1' // => true
!!{}; // => true
!!true; // => true