Method



Write a JavaScript code to illustrate the use of method.

<html>
  <head>
    <title>Method</title>
      <script>

          var student = 
          {
              name: "Vijay",
              age: 21,
              year:"TY",
              
              display: function()
              {
                  return(this.name);
              }
          };
          document.write("Name = " + student.display());
       </script>
    </head>
  <body>       
</body>
</html>

Output:

Name = Vijay