<!DOCTYPE html>
<html>

<head>
     <meta charset="utf-8" />
     <title>The Difference Between Call and Apply in Javascript</title>
     <link rel="stylesheet" href="style.css" />
     <script>
          var var1 = {
               my: "Obj1"
          };

          var var2 = {
               my: "Obj2"
          };

          function preview(par1, par2) {
               alert(this.my + ' ' + par1 + ' ' + par2);
               console.log(this.my, par1, par2);
          }

          //using call as given below
          preview.call(var1, "First", "Second");
          //output: var1 First Second

          //using apply as given below
          preview.apply(var2, ["First", "Second"]);
          //output: var2 First Second

          //using basic as given below
          preview("First", "Second");
          //output: undefined "First", "Second"
     </script>
</head>

<body>
     <div>
          <h3>Refresh the page and see the alert result or go to console window and see the result.</h3></div>
</body>

</html>
/* Put your css in here */

h1 {
  color: red;
}