JSFiddle - React, Tailwind, and code Playground

by habla

JavaScript

/*var Foo = function Foo(){}

Foo.prototype.bar = "100";

var foochild = new Foo();

console.log(Foo.bar);
console.log(foochild.bar);

console.log(Foo.prototype); // Object {bar: "100"}
console.log(foochild.prototype); // undefined


console.log(Object.getPrototypeOf(Foo)); // function () {}
console.log(Object.getPrototypeOf(foochild)); // Object {bar: "100"}
console.log(Object.getPrototypeOf(foochild) == Foo.prototype); */


//var Parsimmon = {};

// The Parser object is a wrapper for a parser function.
// Externally, you use one to parse a string by calling
//   var result = SomeParser.parse('Me Me Me! Parse Me!');
// You should never call the constructor, rather you should
// construct your Parser from the base parsers and the
// parser combinator methods.
function Parser(action) {
  if (!(this instanceof Parser)) return new Parser(action);  
  this._ = action;
}

function string() { return new Parser ( function(){return null;} )};
Parser.string = string;

_ = Parser.prototype;
_.foo = function () {};

var myparser = new Parser.string();
myparser.foo();
//Parser.foo(); //fails
myparser.string(); //fail

console.log('done');