function fn( arg1, arg2,... ){// do something
}fn( arg1, arg2,... );fn.call( context, arg1, arg2,... );fn.apply( context, [ arg1, arg2,... ]);
<!--by oscar999 2013-1-17-->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<script>
var func=new function(){this.a="func"}var newfunc=function(x){var a="newfunc";alert(this.a);alert(x);}newfunc.call(func,"inputParameter1"); /*alert are* func/inputParameter1; not newfunc/inputParameter1*/
</script>
</body>
</html>
function Person(name){this.name = name;this.gender = "male";
}
var person1 = new Person("MM");
var person2 = new Person("YY");
person1.gender = "female";
alert(person2.gender);// male
</script>
<script>
function Person(name){this.name = name;
}
Person.prototype.gender = "female";
var person1 = new Person("MM");
var person2 = new Person("YY");
alert(person2.gender);// male
</script>
版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。
工作时间:8:00-18:00
客服电话
电子邮件
admin@qq.com
扫码二维码
获取最新动态