JavaScript Example (Program)
Learn Details

Q. What is the Syntex of Edit/ Add Object Property Value ?



object.property_name = value

  • Example :

    // Ex 1 : Edit Object Property Value <script>
       var a = {
       FName: "Rohit",
       lName : "Kumar"   
    }
    a.sr_no = "1";
    a.FName="Teach";
    a.lName="Coders"
    
    document.write(a.sr_no+" "+a.FName+" "+a.lName)
       
    </script>
    Out Put : 1 Teach Coders
  • Q. How to Create Object with new Object()

    Onject_name = new Object()

    Example :

    // Create Object with new Object Method <script>
    var a = new Object()
    a.first_name ="Teach";
    a.last_name = "coders";
    document.write(a.first_name+" "+a.last_name)
       
    </script>
    Out Put : Teach coders