one.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>function this 的使用</title>
</head>
<body>
<script type="text/javascript" language="javascript">
cls=function(data){
this.showA=function (a){
alert(a);
};
//showA(‘showA‘);
this.showA("ccc")
function showB(b){
alert(b);
};
showB("ddd")
function showData(data){
alert(data);
};
}
var c=new cls("simone");
c.showA("asmone");
c.showB("tt");
cls.showB("b");
cls.showData("wang");
alert(cls("simone"));
</script>
</body>
</html>
two.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>function : 的使用</title>
</head>
<body>
<script type="text/javascript" language="javascript">
var FN=function(s){
alert(‘fn‘);
alert(s);
return{
nopar:function(){alert(‘nopar‘)},
onepar:function(p){alert(‘onepar‘);alert(p)},
shows:function(){alert(s)},
shows2:function(s){alert(s)}
}
}
fn=new FN(‘onefn‘);
fn.nopar();
fn.onepar(‘ts‘);
fn.shows();
fn.shows2(‘tbb‘);
alert(‘******************‘);
var FN2={
one:function(){alert(‘one‘)},
two:function(p){alert(p),alert(this)},
three:function(){
this.one();
alert(‘three‘);
function in_three(){
alert(‘in_three‘);
};
this.this_three=function(){
alert(‘this_three‘);
};
}
};
FN2.one();
FN2.two(‘fn2 two‘);
FN2.three();
var three2=FN2.three;
alert(‘########‘);
var th=new three2();//去掉this.one()这一语句后,可以new成功
th.this_three();
</script>
</body>
</html>