By Object() constructor:
var obj = new Object();
By Object.create() method:
Object.create: Will return a new object with properties of prototypeObject.
var obj = Object.create(prototypeObject);
By brackets:
It is the same as Object.create() method with a null parameter.
var obj = {};
By function constructor:
var MySite = function(website) { this.website = website; } var obj = new MySite("w3schools.com");
By function constructor with prototype:
function MySite(){}; MySite.prototype.name = "w3schools.com"; var obj = new MySite();
By ES6 class syntax:
class MySite { constructor(name) { this.name = name; } } var obj = new MySite("w3schools.com");
By Singleton pattern:
var obj = new function(){ this.name = "w3schools.com"; }
Related topics:
- What is JavaScript?
- JavaScript advantages and disadvantages
- Javascript External file
- Javascript isNaN()
- Javascript Undefined and Null
- Javascript Create object
- JavaScript access cookie
- Javascript read cookie
- Javascript get cookie by name
- Javascript detete cookie
- Javascript redirect URL
- Javascript print webpage
- Javascript exceptions