Skip to content

Instantly share code, notes, and snippets.

Created Jul 29, 2020
What would you like to do?
// Constructor function
// Not to be used as normal function
function Person(id, name) {
// Was this set to global?
if (this == global)
throw "Error: use 'new Person()'"; = id; = name;
// Expect error here
// let result = Person(1, "Brendan");
function Visitor(id, name, visiting) {, id, name);
this.visiting = visiting;
let ryan = new Visitor(2, "Dahl", "Eich");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment