Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Programming»JavaScript»How to Remove Property from JavaScript Object

    How to Remove Property from JavaScript Object

    By RahulOctober 26, 20211 Min Read

    This tutorial will help you to remove property of a JavaScript object using ‘delete’ operator. On successful deletion, it will return true, else false will be returned. It removes the property value as well as an object property.

    Advertisement

    Remove JavaScript Object Property

    For this example, we have created an object with some default values.

    1
    2
    3
    4
    5
    var obj = {
        "webid": "101",
        "webname": "TecAdmin",
        "domain": "www.example.com"
    };

    Now, use the delete operator to delete the specific property from the JavaScript object.

    1
    delete obj.domain;

    Similarly, you can also use the following syntax with the delete operator.

    1
    delete obj['domain'];

    Example to Remove JavaScript Object Property

    Below is a working example of removing the property from a javascript object. Add below content in an HTML file and access it in a web browser. Now open the console in the browser to view the results.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    var obj = {
        "webid": "101",
        "webname": "TecAdmin"
        "regex": "^https://.*"
    };
    console.log('-- Object data before remove --');
    console.log(obj);
     
    delete obj.regex;
     
    console.log('-- Object data after remove --');
    console.log(obj);

    Conclusion

    In this quick faq, you have learned to remove a properly from a JavaScript object.

    javascript js
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    JavaScript Techniques for Determining Past Dates

    Mastering Variables and Data Types in JavaScript: A Comprehensive Guide

    Mastering Functions in JavaScript: Essential Concepts and Techniques for Efficient Code

    View 1 Comment

    1 Comment

    1. inigo joseph on January 2, 2018 11:52 am

      Thanks a lot very much for the high your blog post quality and results-oriented help. I won’t think twice to endorse to anybody who wants and needs support about this area.

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • A Comprehensive Look at the Simple Mail Transfer Protocol (SMTP)
    • Understanding Basic Git Workflow: Add, Commit, Push
    • The Difference Between Git Reset –soft, –mixed, and –hard
    • Understanding the Staging Area in Git’s Workflow
    • Python Function with Parameters, Return and Data Types
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.