ECMAScriptの規格書は非常に細部に至るまで細かく仕様が規定されていますが、100%全て正しく実装している処理系は僕の知る限りありません。過去に広まってしまったソフトとの後方互換性を維持するため、あえて仕様にあわせていないのだろうというものもあります。ECMAScriptの規格と各ブラウザのScriptエンジンとの違いは、いずれ機会があればまとめたいと思っていますが、コーナーケース(いわゆる重箱の隅系)になると、膨大な量になります。 今回は、文字列を数値に変換する際に登場するToNumberとparseInt/parseFloatについて簡単に紹介します。ToNumberは規格書に登場する内部の実装関数であり、parseInt/parseFloatはご存知JavaScriptのグローバル関数です。 ToNumberの引数が文字列のとき、規格書ではその文字列の文法が厳密に規定されていて
An integer parsed from the given string, or NaN when the radix as a 32-bit integer is smaller than 2 or bigger than 36, or the first non-whitespace character cannot be converted to a number. Note: JavaScript does not have the distinction of "floating point numbers" and "integers" on the language level. parseInt() and parseFloat() only differ in their parsing behavior, but not necessarily their ret
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く