---------------------------JS Code---------------------------
function User () {
Definition and constructors of class members
this.name = "Hello";
This.age = 25;
This.sayhello = function () {
Console.log ("Here is Class1");
}
}
-------------------------HTML page-------------------------
<script type= "Text/javascript" src= "Demo01.js" ></script>
<script type= "Text/javascript" >
var u = new User ();
var say = new U.sayhello ();
Console.log (typeof (say))
</script>
Summary: There is no difference between a global function and a function defined as an object method, because global functions and variables can be thought of as methods and properties of the Window object. You can also use the new operator to manipulate an object's methods to return an object, so that the method of an object can be defined as the form of a class, where the this pointer points to the newly created object.
JS Learning (v)-global function and class intrinsic function difference