The delete operator deletes a property from an object - Javascript Operator

Javascript examples for Operator:delete

Introduction

The delete operator deletes both the value of the property and the property itself from object.

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<p id="demo"></p>

<script>
var person = {/*from  www  .  j av  a2  s. c o m*/
    firstname:"Mary",
    lastname:"Bond",
    age:50,
    eyecolor:"blue"
};
delete person.age;
document.getElementById("demo").innerHTML =
person.firstname + " is " + person.age + " years old.";
</script>

</body>
</html>

Related Tutorials