JavaScript Bind
'use strict'; var jane = { name: 'Jane', describe: function() { return 'Person named ' + this.name; } }; var func = jane.describe; func(); //TypeError: Cannot read property 'name' of undefined var func2 = jane.describe.bind(jane);
JS里的bind概念基本和C++是一样的,要有对象。
Protoss a good race, do not change it.