JavaScript Example (Program)
Learn Details

Q. What is the Syntex of Object With object Value ?



objectName.innerobj_name.propertyname

  • Example :

    // Ex 1 : Program(with function & using without this keyword) <script>
       var emp = {
          Devloper:{
             Name:"Rohit Kumar",
             salary: 25000,
          }
       }
       document.write(
             "Name : "+emp.Devloper.Name+"<br>"
             +"Salary : "+emp.Devloper.salary+"<br>"
          )
       
    </script>
    Out Put : suresh Singh Ram Kumar

    // ex 2 : Program(with function & using with this keyword) <script>
    var a = {
       fname : ["Ram", "suresh", "Ganesh"],
       lname :["Kumar", "Singh", "Gupta"],
       fullname: function myfunc(){
          return this.fname[1]+" " +this.lname[1]
       }
    }
    document.write(a.fullname()); 
       
    </script>
    Out Put : Name : Rohit Kumar
    Salary : 25000