JavaScript Example (Program)
Learn Details

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



objectNamae.propertyName(function_name)

Note: किसी function में किसी object ke property को call करने के this.object_property_name का use किया जाता है


  • Example :

    // Ex 1 : Program(with function & using without this keyword) <script>
    var a = {
       fname : ["Ram", "suresh", "Ganesh"],
       lname :["Kumar", "Singh", "Gupta"],
       fullname: function myfunc(){
          return a.fname[1]+" " +a.lname[1]
       }
    }
    document.write(a.fullname()); 
       
    </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 : suresh Singh