JS总结2--(方法和函数)
2010-09-01 14:33
316 查看
三、继承的实现
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("到底了!");
}
});
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("到底了!");
}
});
相关文章推荐
- js 使用方法与函数 总结第1/4页
- js 函数,方法总结
- js调用cs中函数的方法 和 在cs中调用js函数的方法〔总结〕
- [Asp.net+JS]asp.net中调用javascript自定义函数的方法总结
- [Asp.net+JS]asp.net中调用javascript自定义函数的方法总结
- js 使用方法与函数 总结第1/4页
- js正则及常用方法函数总结
- JS中把函数作为另一函数的参数传递方法(总结)
- JS 将变量 转化为字符串的方法, 适用于所有类型,数组, 对象,函数和基本类型等
- js实现页面自动刷新方法总结(转)
- JS日期(Date)处理函数总结
- Html下拉框Js对象属性方法总结
- vue.js中生命周期与相关函数的使用总结
- js二维数组定义和初始化的三种方法总结
- js函数的多种定义方法与其区别
- 同步异步动态引入js文件的几种方法总结
- js字母大小写转换实现方法总结
- js调用cs中函数的方法
- js调用.net后台事件,和后台调用前台等方法总结(转帖)
- js 获取函数的所有参数和遍历JavaScript某个对象所有的属性名称和值的方法