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++是一样的,要有对象。

posted @ 2014-04-12 13:48  LambdaTea  阅读(503)  评论(0编辑  收藏  举报