

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to work with delete operator in JavaScript?
Use the delete property in JavaScript, to remove a property from an object. You can try to run the following code to learn how to work with delete operator. Here, we are deleting the book price −
Example
Live Demo<html> <head> <title>JavaScript Delete Operator</title> <script> function book(title, author) { this.title = title; this.author = author; } </script> </head> <body> <script> var myBook = new book("WordPress Development", "Amit"); book.prototype.price = null; myBook.price = 500; document.write("<h2>Details before deleting book price</h2>"); document.write("Book title is : " + myBook.title + "<br>"); document.write("Book author is : " + myBook.author + "<br>"); document.write("Book price is : " + myBook.price); delete myBook.price; document.write("<br><h2>Details after deleting book price</h2>"); document.write("Book title is : " + myBook.title + "<br>"); document.write("Book author is : " + myBook.author + "<br>"); document.write("Book price is : " + myBook.price + "<br>"); </script> </body> </html>
- Related Questions & Answers
- How to delete a getter using the delete operator in JavaScript?
- How to delete a setter using the delete operator in JavaScript?
- How to work with Structs in JavaScript?
- How to work with document.anchors in JavaScript?
- How to work with document.body in JavaScript?
- How to work with document.embeds in JavaScript?
- How to work with document.documentElement in JavaScript?
- How to work with document.head in JavaScript?
- How to work with document.forms in JavaScript?
- How to work with document.images in JavaScript?
- How to work with document.links in JavaScript?
- How to work with document.title in JavaScript?
- What is 'delete' Operator in JavaScript?
- delete() operator in C++
- How does comparison operator work with date values in MySQL?
Advertisements