3 ms·
It allows you to inherit functions from a prototype and still have them execute against the current receiver. Consider: var base = { greet: function(
by munificent 16y ago
It allows you to inherit functions from a prototype and still have them execute against the current receiver. Consider:
var base = {
greet: function() { log('my name is ' + this.name); },
name: 'base'
}
var derived {
__proto__: base,
name: 'derived'
}
derived.greet();
If the greet function was bound at creation time to base, then the last line would print "my name is base" instead of the desired "my name is derived".