Javascript Objects

Here’s my preferred way of making objects in javascript:

// constructor
function Person(name, age) {
// instance variables
this.name = name;
this.age = age;
}

// private variables
var pop = 0;

// instance methods
Person.prototype.sayName = function() {
console.log(this.name);
}

// static methods
Person.population = function() {
return pop;
}

// static variables
Person.numLegs = 2;

// private methods
function getAge() {}

module.export and export in node.js

Took me awhile to find the answer to this, but I finally understand the difference between module.exports and exports. Essentially exports is a helper variable that node.js uses to populate the module.exports object. This object is this object that is actually being returned by a require statement. If you reassign exports to something else, then the object being returned will not contain what you think it will. If you don’t reassign anything, then module.exports and exports are essentially interchangeable.

What’s Really Going On in the Chinese Bitcoin Community

An article Rui Ma of 500 Startups and I wrote about the Chinese Bitcoin community, published by Techinasia on November 28, 2013.  Comments welcome!

Restart

Dammit.  I accidentally deleted this blog app from heroku, so here I am starting over.  It’s too bad; I had some really good stuff on the last one too.  Trust me.