js 的一些语法问题,求助
foo = {
'bar': function () {
alert(this);
},
'toString': function () {
return 'foo';
}
};
foo.bar();//返回的是"foo"
(foo.bar)();//返回的是"[object Window]"
(foo.bar || null)();//返回的是"[object Window]"
bar = foo.bar; bar();//返回的是"[object Window]"
这个是为什么啊,还有如果是foo.bar,这个有意义吗,为什么
Object.prototype.extend = function(object) {
for (property in object) {
this[property] = object[property];
}
return this;
}
可以实现
function extend(ob1, ob2) {
for (property in ob2) {
ob1[property] = ob2[property];
}
return ob1;
}
不能实现
这个又是为什么?
问题多了点,麻烦各位大哥啦:)