javascript 基础(基本对象函数)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html lang="en"> 
<head> 
   <script type="text/javascript"> 
   function clickobject(){ 
var obj=new Object(); 
obj.name="a object!!!"; 
obj.sayhi=function(){ 
 alert("hi"); 
 document.write("hello!world\n"); 
 document.write(typeof obj); 
 document.write(obj.name.length); 
      } 
    obj.sayhi(); 
} 
function clickstring(){ 
var string ="hello!"; 
var string1=new String('hello world!'); 
var saystring=function(){ 
  alert(string.length); 
  alert(string1.length); 
} 
saystring(); 
} 
</script> 
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> 
<title>js object</title> 
</head> 
<input type="button" onclick="javascript:clickobject()" value="getobject" /> 
<input type="button"  onclick="javascript:clickstring()"  value="getstring" /> 
<body> 
</body> 
</html> 
////一个函数返回多个值
function(x,y){
this.x=x;
this.y=y;
return {xx:this.x,yy:this.y};
}

你可能感兴趣的:(javascript 基础(基本对象函数))