クロクロ・ショップ
サイトTOP

JavaScriptエラーメッセージ大研究

twitter ツイッターはこちら
pixiv fanbox
開発支援はこちら
ツイート@rutenさんをフォロー
表紙画像

 JavaScriptのエラー メッセージについて、サンプル コードと、Chrome、Firefoxでのログを掲載して解説した本です。

 JavaScriptのエラーについて詳しくなれる研究本です。

サンプル コード

詳細情報

 プログラミングの初心者は、エラー メッセージを読まないことが多いです。そのため初心者にプログラミングを教える際は、エラー メッセージを読むこと、その内容を調べることを伝えます。また JavaScript では、MDNの「JavaScript エラーリファレンス」エラー メッセージがまとまっているため、よくすすめます。

 しかし、このページを他人によくすすめる割には、内容を全て検証したことはありませんでした。そして「これではよくない」と思いました。

 本書では、MDN の「JavaScript エラーリファレンス」を元に、その全てをサンプル コードを書いて検証しました。実際に実行すると、Chrome と Firefox でエラー メッセージが異なっていたり、挙動が違っていたりすることが分かります。本書では、このサンプル コードとエラー メッセージを全て掲載して解説しています。

 本書で取り上げている項目は、2022年9月1日時点で MDN の「JavaScript エラーリファレンス」に掲載されているものです。サンプル コードとともに、実際にはどのようなエラーが発生するのかを確認してください。

 簡略化した目次は、以下になります。詳細な目次は、さらに下で示します。

まえがき
第1章:ReferenceError
第2章:SyntaxError
第3章:TypeError
第4章:RangeError
第5章:URIError、InternalError、Error
第6章:Warning
あとがき
巻末付録

目次

まえがき
第1章:ReferenceError
  1-1 "x" is not defined
  1-2 assignment to undeclared variable "x"
  1-3 can't access lexical declaration'X' before initialization
  1-4 deprecated caller or arguments usage
  1-5 invalid assignment left-hand side
  1-6 reference to undefined property "x"
第2章:SyntaxError
  2-1 "0"-prefixed octal literals and octal escape seq. are deprecated
  2-2 "use strict" not allowed in function with non-simple parameters
  2-3 "x" is a reserved identifier
  2-4 JSON.parse: bad parsing
  2-5 Malformed formal parameter
  2-6 Unexpected token
  2-7 Using //@ to indicate sourceURL pragmas is deprecated. Use //# instead
  2-8 a declaration in the head of a for-of loop can't have an initializer
  2-9 applying the 'delete' operator to an unqualified name is deprecated
  2-10 for-in loop head declarations may not have initializers
  2-11 function statement requires a name
  2-12 identifier starts immediately after numeric literal
  2-13 illegal character
  2-14 invalid regular expression flag "x"
  2-15 missing ) after argument list
  2-16 missing ) after condition
  2-17 missing : after property id
  2-18 missing ; before statement
  2-19 missing = in const declaration
  2-20 missing ] after element list
  2-21 missing formal parameter
  2-22 missing name after . operator
  2-23 missing variable name
  2-24 missing } after function body
  2-25 missing } after property list
  2-26 redeclaration of formal parameter "x"
  2-27 return not in function
  2-28 test for equality (==) mistyped as assignment (=)?
  2-29 unterminated string literal
第3章:TypeError
  3-1 "x" has no properties
  3-2 "x" is (not) "y"
  3-3 "x" is not a constructor
  3-4 "x" is not a function
  3-5 "x" is not a non-null object
  3-6 "x" is read-only
  3-7 'x' is not iterable
  3-8 More arguments needed
  3-9 Reduce of empty array with no initial value
  3-10 X.prototype.y called on incompatible type
  3-11 can't access dead object
  3-12 can't assign to property "x" on "y": not an object
  3-13 can't define property "x": "obj" is not extensible
  3-14 can't delete non-configurable array element
  3-15 can't redefine non-configurable property "x"
  3-16 cannot use 'in' operator to search for 'x' in 'y'
  3-17 cyclic object value
  3-18 invalid 'instanceof' operand 'x'
  3-19 invalid Array.prototype.sort argument
  3-20 invalid assignment to const "x"
  3-21 property "x" is non-configurable and can't be deleted
  3-22 setting getter-only property "x"
第4章:RangeError
  4-1 argument is not a valid code point
  4-2 invalid array length
  4-3 invalid date
  4-4 precision is out of range
  4-5 radix must be an integer
  4-6 repeat count must be less than infinity
  4-7 repeat count must be non-negative
第5章:URIError、InternalError、Error
  5-1 malformed URI sequence
  5-2 too much recursion
  5-3 Permission denied to access property "x"
第6章:Warning
  6-1 08/09 is not a legal ECMA-262 octal constant
  6-2 -file- is being assigned a //# sourceMappingURL, but already has one
  6-3 Date.prototype.toLocaleFormat is deprecated
  6-4 String.x is deprecated; use String.prototype.x instead
  6-5 expression closures are deprecated
  6-6 unreachable code after return statement
あとがき
巻末付録

プレビュー

 本のページのサンプルです。



QR コード

情報

著作権者 : 柳井 政和

Web Site : http://crocro.com/

This Page : https://crocro.com/shop/item/js_error_study.html

Twitter : ruten