Skip to content

Instantly share code, notes, and snippets.

View wgottschalk's full-sized avatar

William Gottschalk wgottschalk

  • Snap Inc.
  • Los Angeles
View GitHub Profile
class Parent {
constructor(name) {
this.name = name;
}
}
Parent.prototype.greet = () => {
console.log(`Hi, I'm ${this.name}`);
}
var mom = new Parent("Mom");
mom.greet() // "Hi, I'm Mom"
class Parent {
constructor(name) {
this.name = name;
}
greet() {
console.log(`Hi, I'm ${this.name}`);
}
}
var mom = new Parent("Mom");
@wgottschalk
wgottschalk / newKeywordFunction.js
Created January 14, 2016 19:18
An implementation of the new Keyword in Javascript
function NEW(constructor, argsArray) {
var obj = {}; // step 1
obj.__proto__ = constructor.prototype; // step 2
constructor.apply(obj, argsArray); // step 3
return obj; // step 4
}
function Parent(name) {
this.name = name;
}
Parent.prototype.greet = function() {
var test = "hello world"
@wgottschalk
wgottschalk / testing.js
Created January 14, 2016 17:54
this is a test
var test = hello world