This emphasizes the difference between static and prototype properties.
Given:
function foo(opt_num) { if (opt_num !== undefined) { this.bar = opt_num; } } foo.prototype.bar = 17; foo.bar = 42;
We have both a static property and a prototype property with the same name. However, they refer in different ways:
console.log((new foo()).bar); // 17 console.log((new foo(0)).bar); // 0 console.log(foo.bar); // 42
So, in the external, when you define properties for a type - you usually want to define them on a prototype object:
function log(obj_foo) {
source share