function Person() { this.init()}Person.PRototype = { constructor: Person, init: function() { document.documentElement.addEventListener('click', this, false) }, handleEvent: function(event) { this.say() }, say: function() { alert('hello world!') }}var person = new Person()
function Person() { this.init()}Person.prototype = { constructor: Person, init: function() { document.documentElement.addEventListener('click', this.handleEvent.bind(this), false) }, handleEvent: function(event) { console.log(event) console.log(this) }}var person = new Person()
function bind(fn, context) { return function() { return fn.apply(context, arguments) }}
新闻热点
疑难解答