delete

Summary

Removes a property or method from a JavaScript object.

Syntax

delete object.property
delete object[property]

Parameters

object
Any valid JavaScript object.
property
The name of a property to delete.

Description

delete removes a property on an object having the external type. Therefore, this operator should only be used in conjunction with JavaScript code rather than JS++ code.

Examples

Delete Property on a JavaScript Object
1
2
3
4
5
6
7
8
9
10
11
import System;
 
var books = {
    "A Tale of Two Cities": "Charles Dickens",
    "The Iliad": "Homer",
    "The Lord of the Rings": "J. R. R. Tolkien"
};
 
Console.log(books["The Iliad"]); // "Homer"
delete books["The Iliad"];
Console.log(books["The Iliad"]); // undefined

See Also

Share

HTML | BBCode | Direct Link