コンテンツへスキップ
科目
  • 1 はじめに
    1.1

    最初のプログラム

    プログラムはコンピュータのための一連の指示のリストです。JavaScriptでは、各指示はステートメントであり、コンピュータは上から下へステートメントを実行します。

    console.log(...) はコンソールに値を出力し、コード下のテキストエリアに表示されます:

    console.log("Hello, world!");
    console.log(7 * 6);   // 42
    
    • テキストは引用符の間に置きます:"Hello" または 'Hello'。数字は置かないでください。
    • 各文の末尾にセミコロン ; を付けてください。JavaScript は欠落している場所を推測することが多いですが、明記した方が親切です。
    • JavaScript は大文字・小文字を区別します:console.log は動作しますが、Console.Log は動作しません。

    console.log で複数の値を一度に出力できます。値の間にスペースが1つ入ります:

    console.log("Total:", 3 + 4);   // Total: 7
    console.log(1, 2, 3);           // 1 2 3
    
    1.2

    コメントとコードスタイル

    コメントは人向けの手書きメモです。プログラム実行中は JavaScript が無視します。

    // A one-line comment starts with two slashes.
    console.log("This line runs");   // a comment can follow code
    
    /* A block comment
       can cover several lines. */
    console.log("So does this one");
    

    良いスタイルはコードを読みやすくします:

    • { } の中の行には2つまたは4つのスペースでインデントし、常に同じ方法で統一してください。
    • 変数名は格納する内容を示すように名付けます:total とし、t にしないようにしてください。
    • JavaScript の変数名には camelCase を使用します:firstName、scoreTotal。
    // Work out the area of a rectangle
    const width = 4;
    const height = 3;
    console.log(width * height);   // 12
    

    ** 一般的なミス **

    • テキストには対応する引用符が必要です:"Hi' はエラーです。
    • console.log はすべて小文字である必要があります:Console.log と console.Log はエラーです。
    • 行内の // の以降は無視されるため、// console.log(x) は何も出力しません。
  • 2 Values, variables & types
    2.1

    let と const

    変数は値を格納する名前付き箱です。let または const で作成し、その名前で利用します:

    let score = 10;
    score = score + 5;      // let: the value can change
    console.log(score);     // 15
    
    const name = "Mei";     // const: the name cannot be reassigned
    console.log(name);      // Mei
    
    • = は代入を意味します:右辺を計算し、左辺の箱に格納します。
    • デフォルトでは const を使用します。値が後から変更される必要がある場合にのみ let を使用します。
    • const の再代入はエラーです:name = "Tom" は許可されていません。const のオブジェクトや配列でも中身の変更は可能です。
    2.2

    数値と数学演算

    これらの例では整数および小数値用の number タイプを使用しています。BigInt は別の整数型です。算術演算子は以下の通りです:

    演算子 意味 例 結果
    + - 加算、減算 7 - 2 5
    * / 乗算・除算 7 / 2 3.5
    % 余り 7 % 2 1
    ** べき乗 2 ** 3 8
    console.log(7 / 2);              // 3.5
    console.log(Math.floor(7 / 2));  // 3   (whole-number division)
    console.log(7 % 2);              // 1   (odd numbers leave 1)
    console.log(2 + 3 * 4);          // 14  (* before +)
    console.log((2 + 3) * 4);        // 20
    

    Math は便利な関数を含みます:

    console.log(Math.round(2.5));    // 3
    console.log(Math.max(4, 9, 2));  // 9
    console.log(Math.sqrt(49));      // 7
    
    • Math.random() は 0 以上(1 を除く)の範囲からランダムな数を返します。Math.floor(Math.random() * 6) + 1 は 1 から 6 の範囲でサイコロを振る結果です。
    • 小数は二進法で格納されるため、0.1 + 0.2 は 0.30000000000000004 を表示します。表示する前に四捨五入してください:(0.1 + 0.2).toFixed(2) は "0.30" です。
    2.3

    タイプと変換

    すべての値にはタイプがあります。typeofはそのタイプを示します:

    console.log(typeof 42);         // number
    console.log(typeof "42");       // string
    console.log(typeof true);       // boolean
    console.log(typeof undefined);  // undefined
    
    • let x; で値を代入せずに作られた変数は undefined です。
    • null は「値がない」ことを意味し、意図的に設定されます。

    + に文字列がある場合、加算ではなく結合を行うため、まずテキストを数値に変換する必要があります:

    console.log("5" + 1);           // 51  (joined)
    console.log(Number("5") + 1);   // 6   (added)
    console.log(parseInt("12px"));  // 12  (reads the number at the start)
    console.log(String(9) + "!");   // 9!
    
    • 数値ではないテキストは NaN ("not a number")を返します:Number("abc") は NaN です。
    • - 、* 、/ は単独でテキストを数値に変換できます("6" * 2 は 12 )、但这に依存せず、意図的に行ってください。

    ** 一般的なミス **

    • =は代入であり、比較ではありません。比較には===を使用します(トピック4)。
    • "5" + 1 は "51" です。数学演算を行う前に Number(...) で入力を変換してください。
    • Math.round(2.5) は 3 ですが、Math.round(-2.5) は -2 です:半端な値は大きい方へ丸めます。
  • 3 文字列
    3.1

    文字と長さ

    文字列は引用符で囲まれたテキストです。単純なアルファベットの場合、各文字は1つの位置(インデックス)を持ちます。最初のインデックスは 0 です。JavaScript は UTF-16 コード単位をカウントするため、絵文字が2つの位置を占めることがあります。

    const word = "Script";
    console.log(word.length);     // 6
    console.log(word[0]);         // S
    console.log(word[2]);         // r
    console.log(word.at(-1));     // t  (counts back from the end)
    console.log(word[word.length - 1]);   // t
    
    • 最後のインデックスは length - 1 です。word[6] は undefined を返すだけで、エラーではありません。
    • 文字列は不変です:word[0] = "s" で文字列を変更しようとすると厳密モードで TypeError が発生します。新しい文字列を作成してください。

    文字列を結合するには + を使い、これを連結と呼びます:

    const first = "Ada";
    const last = "Lovelace";
    console.log(first + " " + last);   // Ada Lovelace
    
    3.2

    String メソッド

    メソッドは値に属する関数です。ドットを使って呼び出します。文字列メソッドは新しい値を返し、元の値は変更しません。

    const city = "  Hong Kong ";
    console.log(city.trim());                 // Hong Kong
    console.log(city.trim().toUpperCase());   // HONG KONG
    console.log(city.length);                 // 12  (the spaces are still there)
    
    メソッド 意味 例 結果
    .toUpperCase() / .toLowerCase() 大文字・小文字の変換 "Hi".toLowerCase() "hi"
    .trim() 両端のスペースを削除 " hi ".trim() "hi"
    .includes(t) t を含みますか? "cat".includes("a") true
    .indexOf(t) t の最初の位置、または -1 "cat".indexOf("t") 2
    .slice(a, b) aからbまで(含まれない)の文字列 "Script".slice(0, 3) "Scr"
    .split(sep) アレイに分割 "a,b,c".split(",") ["a","b","c"]
    .replace(a, b) 最初の a を b に交換 "cat".replace("c", "b") "bat"
    const email = "[email protected]";
    const at = email.indexOf("@");
    console.log(email.slice(0, at));          // mei
    console.log(email.slice(at + 1));         // school.org
    console.log(email.split("@"));            // ["mei","school.org"]
    
    3.3

    テンプレートリテラル

    テンプレートリテラルはバックスラッシュで囲まれた文字列です(ほとんどのキーボードでは 1 の左側にあるキー)。${ } 内に式を記述すると、その値がテキストに埋め込まれます:

    const name = "Mei";
    const age = 17;
    console.log(`${name} is ${age} years old.`);   // Mei is 17 years old.
    console.log(`Next year: ${age + 1}`);          // Next year: 18
    
    • バックスラッシュには複数行のテキストも格納できます。
    • 多くの + 記号よりも読みやすいです:"Hi " + name + "!" と `Hi ${name}!` を比較してください。
    const price = 4.5;
    console.log(`Two cost $${(price * 2).toFixed(2)}`);   // Two cost $9.00
    

    ** 一般的なミス **

    • ${ } はバックスラッシュ内でのみ機能します。"Hi ${name}" では、入力通りそのまま表示されます。
    • メソッドは文字列自体を変化させません。単独の city.trim() は何も起こしません。結果を保存してください:const clean = city.trim(); 。
    • slice(a, b) は b より手前で停止します。最終インデックスが length - 1 であるのと同じ原理です。
  • 4 Decisions
    4.1

    ブール値と比較演算子

    ブール値は true か false のどちらかです。比較演算子はブール値を返します:

    演算子 意味 例 結果
    === 等しい(値と型が同じ) 5 === 5 true
    !== 等しくない 5 !== 3 true
    < > 未満、大以上 2 > 7 false
    <= >= 以下、以上 7 >= 7 true
    console.log(5 === 5);     // true
    console.log(5 === "5");   // false  (a number is not a string)
    console.log(5 == "5");    // true   (== converts first: avoid it)
    
    • 常に === と !== を使用してください。古い == は型変換を行って、予期しない結果を返すことがあります。

    ブール条件には、以下の論理演算子を使用します。他の値に対しては、&& と || は自身の操作数のいずれかを返しますが、常にブール値を返すとは限りません:

    • && (and):両方の側が真の場合のみ真です。
    • || (or):少なくとも片方が真であれば真です。
    • ! (not):true を false に変換し、その逆も行います。
    const age = 15;
    console.log(age >= 13 && age <= 19);   // true   (a teenager)
    console.log(age < 5 || age > 65);      // false
    console.log(!(age > 18));              // true
    
    4.2

    if / else if / else

    if 文は、条件が真理値として扱われる(真とみなされる)場合にコードブロックを実行します。ブール条件の場合、これは値 true を意味します。else if は別の条件を検査し、else は残りをすべてキャッチします:

    const mark = 72;
    if (mark >= 80) {
      console.log("A");
    } else if (mark >= 60) {
      console.log("B");
    } else {
      console.log("C");
    }
    // prints B
    
    • JavaScript は条件を上から順にチェックし、最初の真の分岐のみを実行します。
    • 条件は丸括弧で囲み、実行するコードは波括弧 { } で囲みます。

    したがって順序が重要です。最も厳密なテストを最初に配置してください:

    const temp = 35;
    if (temp > 30) {
      console.log("hot");
    } else if (temp > 20) {
      console.log("warm");   // skipped: the first branch already ran
    }
    // prints hot
    
    4.3

    スイッチ

    switch はある値を複数の固定されたケースと比較します。すべてのテストが「…と等しいか?」である場合、長い else if の連なりよりもすっきりしています:

    const day = "Sat";
    switch (day) {
      case "Sat":
      case "Sun":
        console.log("weekend");
        break;
      case "Fri":
        console.log("nearly there");
        break;
      default:
        console.log("school day");
    }
    // prints weekend
    
    • switch は === と比較するため、case 1: は文字列 "1" に一致しません。
    • break は switch を終了します。これがない場合、コードは 次のケースへ fall through(Fall-through) してしまいます。
    • defaultはどのケースにも一致しない場合に実行され、最終的なelseのような役割を果たす。
    • 間にコードのない2つのケースは同じコードを共有します。"Sat" と "Sun" も同様に動作します。

    ** 一般的なミス **

    • if (x = 5) は比較ではなく代入を行うため、テストは常に真になります。if (x === 5) を書くべきです。
    • if (age > 13 && < 19) はエラーです:変数を重複させてください、age > 13 && age < 19 。
    • switch 内の break が欠けていると、次のケースも実行されてしまいます。
  • 5 ループ
    5.1

    for ループ

    for ループの3つの部分と、それらが実行される順序

    ループはコードブロックを繰り返します。繰り返す回数が既知の場合は、for ループが最適です。その括弧内には3つの部分が半角カマタで区切られて含まれます:

    for (let i = 1; i <= 3; i++) {
      console.log(i);
    }
    // 1
    // 2
    // 3
    
    1. start(初期化):let i = 1 はループ开始前に一度だけ実行されます。
    2. condition(条件):i <= 3 は各反復开始前に検査され、偽になればループは停止します。
    3. step(ステップ):i++ (1 を i に加算)は各反復後に実行されます。

    ループの各反復は1つのイテレーションです。ステップを他の方法でカウントするには:

    let line = "";
    for (let i = 10; i > 0; i -= 3) {
      line += i + " ";
    }
    console.log(line);   // 10 7 4 1
    

    累積パターンでは、ループ前に変数を作成し、各反復で更新します:

    let total = 0;
    for (let n = 1; n <= 5; n++) {
      total += n;          // the same as total = total + n
    }
    console.log(total);    // 15
    
    5.2

    while ループ

    while ループは条件が真である間繰り返されます。何回反復する必要があるかを事前に知らない場合に使用します:

    let money = 100;
    let years = 0;
    while (money < 200) {
      money = money * 1.1;   // 10% interest each year
      years++;
    }
    console.log(years);      // 8
    
    • 条件は各反復前にチェックされるため、本体がゼロ回実行される可能性があります。
    • 条件が真のまま続き、break やその他の出口に到達しない場合、無限ループになります。(その場合は Stop を押してください。)
    5.3

    for...of, break & continue

    for...of はインデックスを管理することなく、配列(または文字列)のすべての項目を順に访问します:

    const fruits = ["apple", "kiwi", "plum"];
    for (const fruit of fruits) {
      console.log(fruit.toUpperCase());
    }
    // APPLE
    // KIWI
    // PLUM
    

    break はループから即座に抜け出します;continue はこの反復の残りをスキップして次の反復に進みます:

    const marks = [55, 80, -1, 90];
    let sum = 0;
    for (const m of marks) {
      if (m < 0) {
        break;            // -1 means "end of the data"
      }
      if (m < 60) {
        continue;         // skip a fail, keep looping
      }
      sum += m;
    }
    console.log(sum);     // 80
    

    ** 一般的なミス **

    • オフ・バイ・ワン エラー: i < 3 は 0, 1, 2 で実行され、i <= 3 は1回多く実行されます。反復数を数えてください。
    • 合計をループ内で初期化する場合: let total = 0; はループ前に来なければならず、否则 各反復ごとにリセットされてしまいます。
    • while ループは条件が真のまま続き、出口に到達しない限り永遠に実行されます。
  • 6 関数
    6.1

    Parameters & return

    A function 函数 is a reusable piece of code. A function declaration gives it a name, which you can use to call 调用 it:

    function greet(name) {
      return `Hello, ${name}!`;
    }
    
    console.log(greet("Mei"));   // Hello, Mei!
    console.log(greet("Tom"));   // Hello, Tom!
    
    • name is a parameter 参数: a variable that receives a value when the function is called.
    • "Mei" is the argument 实参: the actual value passed in.
    • return sends a value back to the caller and ends the function at once.

    A regular function that reaches its end without returning a value gives back undefined. So return the answer, and let the caller decide whether to print it:

    function area(width, height) {
      return width * height;
    }
    
    const a = area(4, 3);
    console.log(a + 1);          // 13  (a returned value can be used again)
    
    6.2

    アロー関数

    An arrow function 箭头函数 is a shorter way to write a function. Store it in a const:

    const square = (n) => n * n;
    const add = (a, b) => a + b;
    
    console.log(square(5));      // 25
    console.log(add(2, 3));      // 5
    
    • With one expression after =>, its value is returned without writing return.
    • With curly braces you need return again:
    const grade = (mark) => {
      if (mark >= 50) {
        return "pass";
      }
      return "fail";
    };
    console.log(grade(64));      // pass
    

    Arrow functions are often passed to other functions, as you will see with map and filter in topic 7.

    6.3

    Scope

    The scope 作用域 of a variable is the part of the code that can see it. A variable made with let or const inside { } is accessible in that block and its nested scopes. A nested function can keep access after the outer call returns:

    const level = "global";
    
    function show() {
      const inside = "local";
      console.log(level);        // global  (outer variables are visible)
      console.log(inside);       // local
    }
    
    show();
    console.log(typeof inside);  // undefined  (inside does not exist out here)
    
    • A variable made inside a function is a local variable 局部变量; each call gets a fresh one.
    • Pass values in as parameters and get results out with return, instead of changing outer variables from inside a function.

    Common mistakes

    • Forgetting return: the function works out the answer, then gives back undefined.
    • Calling without brackets: greet is the function itself; greet("Mei") runs it.
    • Printing inside the function and printing its result prints twice, or prints undefined.
  • 7 配列
    7.1

    Making & changing arrays

    An array 数组 holds a list of values in order, inside square brackets. Each item is an element 元素, and the first index is 0:

    const scores = [72, 88, 95];
    console.log(scores[0]);        // 72
    console.log(scores.length);    // 3
    scores[1] = 90;                // change one element
    console.log(scores);           // [72,90,95]
    
    • const stops you giving scores a whole new array, but you can still change what is inside it.
    • Reading past the end gives undefined: scores[3] is undefined.

    Add and remove at the end with push and pop:

    const queue = ["Ann", "Ben"];
    queue.push("Cai");             // add to the end
    console.log(queue);            // ["Ann","Ben","Cai"]
    const last = queue.pop();      // remove from the end and return it
    console.log(last);             // Cai
    console.log(queue.length);     // 2
    

    An array can hold arrays. That makes a grid, read with two indexes, row first:

    const grid = [
      [1, 2, 3],
      [4, 5, 6],
    ];
    console.log(grid[1][2]);       // 6  (row 1, column 2)
    
    7.2

    map, filter & reduce

    English

    These methods take a function and apply it to the array elements. They return a new array (or value) without themselves replacing the original items. The function you pass in can still change the original array or its objects:

    • map makes a new array by changing every element.
    • filter keeps only the elements for which the function returns true.
    • reduce combines all the elements into one value, such as a total.
    const prices = [4, 10, 25];
    const withTax = prices.map((p) => p * 1.1);
    console.log(withTax.map((p) => p.toFixed(2)));   // ["4.40","11.00","27.50"]
    
    const cheap = prices.filter((p) => p < 20);
    console.log(cheap);                              // [4,10]
    
    const total = prices.reduce((sum, p) => sum + p, 0);
    console.log(total);                              // 39
    

    In reduce, sum is the accumulator. It starts at the last argument (0) and takes the function's result after each element.

    7.3

    検索とソート

    English
    sort() with no compare function sorts numbers as text
    Method Gives back Example with [5, 8, 2] Result
    .includes(x) true or false .includes(8) true
    .indexOf(x) the first index of x, or -1 .indexOf(2) 2
    .find(f) the first element where f is true .find((n) => n > 6) 8
    .findIndex(f) its index, or -1 .findIndex((n) => n > 6) 1

    sort puts the elements in order. With no function, it sorts them as text, so numbers come out in the wrong order:

    const nums = [10, 9, 100, 1];
    console.log([...nums].sort());                   // [1,10,100,9]   (as text!)
    console.log([...nums].sort((a, b) => a - b));    // [1,9,10,100]
    console.log([...nums].sort((a, b) => b - a));    // [100,10,9,1]
    
    • The compare function returns a negative number when a should come first, and a positive number when b should.
    • sort changes the array itself. [...nums] makes a copy first, so nums keeps its order.

    Common mistakes

    • The last element is arr[arr.length - 1], not arr[arr.length].
    • map and filter do not change the array: store their result.
    • nums.sort() on numbers sorts them as text. Pass (a, b) => a - b.
  • 8 オブジェクト
    8.1

    オブジェクト & プロパティ

    オブジェクトは関連する値を名前でグループ化します。各名前と値のペアはプロパティです。この名前はキーと呼ばれます:

    const pupil = {
      name: "Mei",
      age: 17,
      form: "11A",
    };
    console.log(pupil.name);       // Mei
    console.log(pupil["form"]);    // 11A  (bracket form, with the key as a string)
    
    • ドット (pupil.age) または角括弧 (pupil["age"]) でプロパティにアクセスします。キーが変数にある場合は角括弧を使用します:pupil[field]。
    • 存在しないキーを参照すると undefined が返されます。

    プロパティを変更するか、新しいプロパティを追加するには、割り当てを行います:

    const pupil = { name: "Mei", age: 17 };
    pupil.age = 18;                // change
    pupil.house = "Red";           // add
    console.log(pupil);            // {"name":"Mei","age":18,"house":"Red"}
    
    8.2

    オブジェクトの配列

    レコードのリストはオブジェクトの配列です。トピック 7 の配列メソッドと組み合わせて使用します。

    const pupils = [
      { name: "Mei", mark: 88 },
      { name: "Tom", mark: 64 },
      { name: "Sara", mark: 95 },
    ];
    
    const passed = pupils.filter((p) => p.mark >= 70);
    console.log(passed.map((p) => p.name));            // ["Mei","Sara"]
    
    const best = [...pupils].sort((a, b) => b.mark - a.mark)[0];
    console.log(`${best.name} has the top mark`);       // Sara has the top mark
    

    プロパティの合計を計算するには、reduce またはループを使用します:

    const pupils = [{ mark: 88 }, { mark: 64 }, { mark: 95 }];
    let sum = 0;
    for (const p of pupils) {
      sum += p.mark;
    }
    console.log((sum / pupils.length).toFixed(1));      // 82.3
    
    8.3

    オブジェクトでのループ

    Object.keysはキーの配列を返し、Object.entriesは[key, value]ペアを返すため、以下のようにループできます:

    const stock = { pens: 12, rulers: 0, books: 5 };
    
    console.log(Object.keys(stock));             // ["pens","rulers","books"]
    
    for (const [item, count] of Object.entries(stock)) {
      if (count === 0) {
        console.log(`${item}: sold out`);
      }
    }
    // rulers: sold out
    

    オブジェクトはcountersとして適しています。カウントするものをすべてキーとして使用します。

    const words = ["red", "blue", "red", "red"];
    const counts = {};
    for (const w of words) {
      counts[w] = (counts[w] || 0) + 1;   // 0 the first time the key is seen
    }
    console.log(counts);                  // {"red":3,"blue":1}
    

    ** 一般的なミス **

    • pupil.field は field という名前のキーを探します。キーが変数にある場合は、pupil[field] を書きます。
    • プロパティの間にはコンマを使います。セミコロンではありません:{ name: "Mei", age: 17 } 。
    • for...ofはオブジェクトを直接ループできません。Object.keys(...)またはObject.entries(...)をループしてください。
  • 9 エラー
    9.1

    エラーメッセージの読み方

    JavaScript が処理を続行できない場合、停止してエラーを表示します。最初の単語がエラーの種類を示し、残りの部分に何が間違っているか、どこで起きたかが記載されています。それを読んで、指定された行を確認してください。

    SyntaxError: missing ) after argument list
    ReferenceError: totl is not defined
    TypeError: Cannot read properties of undefined (reading 'length')
    
    エラー 意味 一般的な原因
    SyntaxError コードが正しく書かれていないため何も実行されない 括弧や引用符が欠けている
    ReferenceError 存在しない名前 誤字:totl を total と書くべきところ
    TypeError 値の型が目的と異なる undefined に対して .length を使用している

    ブラウザによって正確な表記は異なりますが、エラーの名前は同じです。このプログラムは各エラーをキャッチしてその名前に出力します:

    try {
      const total = 5;
      console.log(totl);
    } catch (e) {
      console.log(e.name);           // ReferenceError
    }
    
    try {
      const pupil = undefined;
      console.log(pupil.length);
    } catch (e) {
      console.log(e.name);           // TypeError
    }
    

    ある種のミスではエラー自体が出ず、単に間違った答えになることがあります(ロジックエラー)。これを見つけるには、console.log で途中の値を出力し、手動で確認してください。

    9.2

    try, catch & throw

    失敗する可能性のあるコードはtryブロックに入れます。そこでエラーが発生すると、JavaScriptは停止せずcatchへ遷移し、eにエラーが格納されます:

    try {
      JSON.parse("{not valid}");
      console.log("parsed");         // skipped
    } catch (e) {
      console.log("Could not read the data");
    }
    console.log("The program carries on");
    

    独自のコードで throw を使用してエラーを発生させることができます。これにより、関数は悪い入力を明確に拒否でき、間違った答えを返す必要がなくなります:

    function average(list) {
      if (list.length === 0) {
        throw new Error("the list is empty");
      }
      return list.reduce((s, x) => s + x, 0) / list.length;
    }
    
    console.log(average([4, 6]));    // 5
    try {
      average([]);
    } catch (e) {
      console.log(`Error: ${e.message}`);   // Error: the list is empty
    }
    
    • new Error("…")は、そのmessageにあなたのテキストを指定するエラーを作成します。
    • 実際のエラーが発生する可能性のあるデータ読み込みなどのコードのみに try を使用してください。自身のコードのミス隠しに使用しないでください。

    ** 一般的なミス **

    • メッセージをスキップします。最初の行はエラーの種類と原因を示すので、そこから始めます。
    • catch は何も行わず(catch (e) {})、問題を隠蔽します: 少なくとも e.message を出力してください。
    • throw "text" は機能しますが、throw new Error("text") もエラーが発生した場所を記録します。

ログインまたはアカウント作成

IGCSE, A-Level & AP