delete 演算子

オブジェクトのプロパティ、配列の要素、または IDictionary オブジェクトのエントリを削除します。

delete expression

引数

  • expression
    必ず指定します。 プロパティ参照、配列要素、または IDictionary オブジェクトとなる式を指定します。

解説

expression の結果がオブジェクトで、expression に指定したプロパティが存在し、さらにオブジェクトがそのプロパティの削除を禁止している場合は、偽 (false) が返されます。

その他の場合は、真 (true) が返されます。

使用例

delete 演算子の使用例を次に示します。

// Make an object with city names and an index letter.
var cities : Object = {"a" : "Athens" , "b" : "Belgrade", "c" : "Cairo"}

// List the elements in the object.
var key : String;
for (key in cities) {
   print(key + " is in cities, with value " + cities[key]);
}

print("Deleting property b");
delete cities.b;

// List the remaining elements in the object.
for (key in cities) {
   print(key + " is in cities, with value " + cities[key]);
}

このコードの出力は次のようになります。

a is in cities, with value Athens
b is in cities, with value Belgrade
c is in cities, with value Cairo
Deleting property b
a is in cities, with value Athens
c is in cities, with value Cairo

必要条件

Version 3

参照

参照

IDictionary

概念

演算子の優先順位

演算子の一覧