JSFiddle - React, Tailwind, and code Playground

by orchid1

JavaScript

function Person(){
    if(!(this instanceof Person)){
         //here we ensure the "new" keyword is used by doing it internally 
         return new Person();
    }
    this.name = "Edgar"
}
var man = Person();
alert(man.name);//will output "Edgar"
alert(window.name);// The output will be called result in JSFiddle but in a real browser it will be ""