javascript基礎(基本的なオブジェクト関数)

1360 ワード

<!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
"); 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};
}