You should probably read about prototypes .
In the first example, you set the setTitle function on the very same instance of Book that is being created.
In the second example, you use prototype inheritance, in other words, all Books now inherit the same setTitle function.
The second saves memory, and functions are easier to update in all Book instances.
But the first has its own precedents, since you can leave the this header on the header and make the variable private with closures .
function Book(title) { var title = title; this.getTitle = function() {
source share