A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.cdn.mozilla.net/ja/docs/Web/JavaScript/Reference/Errors/Delete_in_strict_mode below:

SyntaxError: applying the 'delete' operator to an unqualified name is deprecated - JavaScript

SyntaxError: applying the 'delete' operator to an unqualified name is deprecated

JavaScript の strict モード専用の例外 "applying the 'delete' operator to an unqualified name is deprecated" は、 delete 演算子を用いて変数を削除しようとしたときに発生します。

エラーメッセージ
SyntaxError: Calling delete on expression not allowed in strict mode (Edge)
SyntaxError: applying the 'delete' operator to an unqualified name is deprecated (Firefox)
SyntaxError: Delete of an unqualified identifier in strict mode. (Chrome)
エラータイプ

strict モード でのみ SyntaxError。

何がうまくいかなかったのか?

JavaScript では、通常の変数を delete 演算子で削除できません。strict モードで、変数を削除しようとするとエラーが発生し、削除できません。

delete 演算子は、オブジェクトのプロパティのみ削除できます。オブジェクトプロパティは、設定可能な場合は "修飾" されます。

よくある予想とは異なり、 delete 演算子は直接的なメモリーの解放とは関係ありません。メモリー管理は、参照の解放によって間接的に行われます。メモリー管理ページと delete 演算子ページで詳細を確認してください。

このエラーは、strict mode モードでのみ発生します。非 strict モードでは、演算子はただ false を返します。

例 変数の内容の解放

JavaScript ではプレーンな変数を削除しようとすると動作せず、 strict モードだとエラーをスローします。

"use strict";

var x;

// ...

delete x;

// SyntaxError: applying the 'delete' operator to an unqualified name
// is deprecated

変数のコンテンツを解放するには、null を設定してください。

"use strict";

var x;

// ...

x = null;

// x can be garbage collected
関連項目

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4