javascript 继承

来源:互联网 发布:浩格云信企业数据服务 编辑:程序博客网 时间:2024/05/01 21:50

<script type="text/javascript">

function Tune(name){

this.name=name;

this.getName=function(){

return "My name is :"+this.name;

}

}

function Person(name,age,ID){

this.age=age;

this.id=ID;

Tune.apply(this,arguments);

this.show=function(){

return (this.getName()+"  "+this.age+"   "+this.id);

}

}

 

Person.prototype=new Tune();

var son=new Person("lining",22,10002);

//alert(son.show());

 

eval("result={/"user1/":{/"name/":/"lining/",/"age/":/"12/"}}");

 

//alert(result.user1.name);

 

function say(hello){

//return function(){

alert(hello);

//}

}

//var l=say("hello world");

//setTimeout("say(/"hello word/")",1000);

 

var str=new Array("A1","B1","C1");

i=parseInt(Math.random()*10%3);

document.writeln(i);

switch(str[i]){

case "A1":alert("1A");break;

case "B1":alert("1B");break;

case "C1":alert("1C");break;

default:alert(str[i])

}

</script>

原创粉丝点击