一般的なコード整形

コードを字下げ・整形して読みやすくします。 動作検証は別途必要です。

入力: テキスト結果: テキスト

テキスト入力

使用例

Read a price calculation in integer cents

入力

function total(cents,qty){return cents*qty;}

Expected answer

function total(cents, qty) {
    return cents * qty;
}
Inspect a retry decision for HTTP 429

入力

if(status===429){retryAfter(30);}

Expected answer

if (status === 429) {
    retryAfter(30);
}
Keep an escaped newline inside a JavaScript string

入力

var forecast="Rain\nSun";show(forecast);

Expected answer

var forecast = "Rain\nSun";
show(forecast);
Keep URL punctuation inside a quoted string

入力

var url="https://example.org/search?q=caf%C3%A9&limit=5";open(url);

Expected answer

var url = "https://example.org/search?q=caf%C3%A9&limit=5";
open(url);
Inspect a JSON round-trip without executing it

入力

function copy(value){return JSON.parse(JSON.stringify(value));}

Expected answer

function copy(value) {
    return JSON.parse(JSON.stringify(value));
}

関連ツール

コード整形

操作の参考資料

元の技術文書を見る (English)