ITの隊長のブログ

ITの隊長のブログです。Rubyを使って仕事しています。最近も色々やっているお(^ω^ = ^ω^)

JavaScriptの「match」について

スポンサードリンク

stringしか受け付けてないようですね。知らんかった。。。

# google developer tool のconsoleにて
> var test = 'test'
> test.match(/[^0-9]/)
["t"]

# 見つからないならnull
> test.match(/[0-9]/)
null

# int型を渡す
> var int_test = 10
> int_test.match(/[0-9]/)
Uncaught TypeError: int_test.match is not a function(…)

そうなんだねー。これで1時間...ショック。