A RetroSearch Logo

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

Search Query:

Showing content from https://developer.cdn.mozilla.net/ko/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 메세지
  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 연산자를 사용하여 삭제할 수 없습니다. 엄격 모드에서 변수를 삭제하는 접근은 허용되지 않으므로 에러가 발생합니다.

delete 연산자는 오직 객체의 속성만을 삭제할 수 있습니다. 객체 속성은 설정할 수 있는 경우 "수식"될 수 있습니다.

일반적인 생각과 다르게 delete 연산자는 메모리 해제와 직접적인 연관이 없습니다. 메모리 관리는 참조가 깨짐에 따라 간접적으로 수행됩니다. 자세한 내용은 메모리 관리 페이지와 delete 연산자 페이지를 참조하십시오.

이 에러는 오직 엄격 모드 코드에서만 발생합니다. 엄격하지 않은 모드에서 해당 연산자는 단순히 false 를 반환합니다.

예제

JavaScript에서 일반 변수를 삭제하려고 하면 동작하지 않습니다. 그리고 엄격 모드에서는 에러가 발생합니다:

"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는 가비지 컬렉터에 의해 메모리에서 해제됩니다
같이 보기

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