三、继承的实现
function Person(name)
{
this.Name = name;
this.sayName = funtcion()
{
alert(this.name);
}
}
function myPerson(name,age)
{
Person.call(this,name); //或 Person.apply(this,new Array(name));
this.Age = age;
this.sayAge = function()
{
alert(this.name);
}
this.say = function()
{
alert(this.Name + "|" + this.Age);
}
}
var a = new myPerson("张三",25);
a.sayName();
a.sayAge()
a.say();
二、获取对象属性个数
Object.prototype.count = (Object.prototype.hasOwnProperty("__count__")) ? function()
{
return this.__count__;
}:function()
{
var count=0;
for(var i in this) if(this.hasOwnProperty(i))
{
count++;
return count;
};
}
var myobj = {
name1:"value1",
name2:"value2"
}
alert(myobj.count());
三、 滚到底触发事件
$(window).bind("sroll",function(){
if($(window).height() + $(document).scrollTop() >= $(document).height())
{
alert("到底了!");
}
});