This site is mobile accessible. Press the "Tap Here" button to use a smaller font-size.



Smartphone icons created by Freepik - Flaticon

JS Functions

In this example, myFunction is a function constructor:

function myFunction(arg1, arg2) {
  this.firstName = arg1;
  this.lastName  = arg2;
}

const myObj = new myFunction("John","Doe");
document.getElementById("demo").innerHTML = myObj.firstName;

A constructor invocation creates a new object. The new object inherits the properties and methods from its constructor.