What is 'delete' Operator in JavaScript?

JavascriptWeb DevelopmentFront End Technology

To remove a property from a JavaScript object, use the delete keyword, which is also called delete operator.

Example

You can try to run the following code to learn how to remove a property −

<!DOCTYPE html>
<html>
   <body>
      <p id="demo"></p>
      <script>
         var cricketer = {
            name:"Amit",
            rank:1,
            points: 400
         };
         deletecricketer.rank;
         document.getElementById("demo").innerHTML=
         cricketer.name + "has " + cricketer.rank + " rank.";
      </script>
   </body>
</html>
raja
Published on 19-Jan-2018 10:00:21
Advertisements