JSFiddle - React, Tailwind, and code Playground

by jasonblewis

HTML

hello world

JavaScript

const greetPrototype = {
  greeting: function(inputobject) {
    this.greet = `${inputobject}, ${this.str}!`;
  },
};

function createGreetable(str) {
  const result = {
    str
  };
  Object.setPrototypeOf(result, greetPrototype);
  return result;
}

const g = createGreetable("world");
console.log("g: ", g);
g.greeting("hello");
console.log("g after hello: ", g);
console.log(g.greet);
console.log("length: ", g.greet.length);