Object With String & Number
JavaScript Example (Program)
Learn Details

Q. What is the Syntex of Object With String & Number ?



objectNamae.propertyName

  • Example :

    // with number <script>
    var a = {
       sr_no : 1, 
       second : 2,
       third : 3,
      }
    document.write(a.second+" "+ a.third)
       
    </script>
    Out Put : 2 5 Ram Kumar

    // ex 2 : Number & String <script>
    var a ={
    fname : "Rohit",
    lname : "Kumar",
    age : 16,
    Marks : 45.5
    }
    document.write(
    "Name : "+a.fname+" "+a.lname+" <br>"+
    "Age : "+ a.age +" <br>"+
    "Marks : "+ a.Marks +" <br>")
       
    </script>
    Out Put : Name : Rohit Kumar
    Age : 16
    Marks : 45.5