Javascript tutorial - 14 - Objects
Dave Partner

Javascript tutorial - 14 - Objects

  • 0 Replies
  • 284 Views

0 Members and 1 Guest are viewing this topic.

*

Offline Dave Partner

  • Administrator
  • Full Member
  • *****
  • 116
    • View Profile
Javascript tutorial - 14 - Objects
« on: November 08, 2016, 05:33:34 AM »




<!DOCTYPE html>
<html>
<head>
   
</head>


<body>
   <script type="text/javascript">
      //javascript Objects
      
      //a collection of properties
      //a property is a key -value pair
      
      var girlFriend = {
            firstName : 'Jolie',
            lastName : 'Angelina',
            height : '6ft',
            rating : 80,
            fullName : function (){
               return this.firstName + ' ' + this.lastName;
            }
      }
      
      document.write(girlFriend['firstName']);
      document.write("<br/>");
      
      document.write(girlFriend.lastName);
      document.write("<br/>");
      
      document.write(girlFriend.fullName());
       document.write("<br/>");
      document.write(girlFriend['fullName']());
      
   </script>
</body>
</html>