您的位置:首页 > 职场人生

职业与事业的概念a

2011-06-04 00:00 169 查看
var cat = {
sound: 'miaow',
speak: function(){
alert(this.sound);
}
};
var dog = {
sound: 'woof',
speak: function(){
alert(this.sound);
}
};
cat.speak(); // alerts 'miaow'
dog.speak(); // alerts 'woof'
Ext.bind(dog.speak, cat)(); // alerts 'miaow'


How it works:
The Ext.bind method creates a wrapper function for the speak method that will force it
to have its scope set to the object that is passed in, overriding the default scope value. This
new function can be executed immediately (as our example did) or stored in a variable to be
executed at a later point.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: