Learning and using JavaScript to create objects

Source: Internet
Author: User

123<meta charset= "Utf-8" >4Learning of <title>javascript Objects </title>56<body>78<script language= "JavaScript" >9document.write (");Ten         varperson=NewObject (); OnePerson.id= "10010"; APerson.name= "Heart Grow Fonder"; -Person.age=22; -person.sex= "Male"; theperson.eat=function(){ -document.write ("Eat () method: Men like to eat high-calorie food!" "); -         } -person.run=function(){ +document.write ("Run () method: The programmer must consciously exercise the body yo!" "); -         } +document.write ("No.:" +person.id+ "<br/>"); Adocument.write ("Name:" +person.name+ "<br/>"); atdocument.write ("Age: +person.age+" <br/> "); -document.write ("Gender:" +person.sex+ "<br/>"); - person.eat (); -document.write ("<br/>"); - Person.run (); -document.write ("<br/>"); indocument.write ("); -         varperson=NewPerson ("10011", "Xiao Li", 23, "male"); to         functionPerson (id,name,age,sex) { +              This. id=ID; -              This. name=name; the              This. age=Age ; *              This. sex=sex; $              This. eat=function(){Panax Notoginsengdocument.write ("Eat () method: Women should eat low-calorie food yo!" "); -             } the              This. run=function(){ +document.write ("Run () method: The female programmer also must consciously exercise the body yo!" "); A             } the         } +document.write ("No.:" +person.id+ "<br/>"); -document.write ("Name:" +person.name+ "<br/>"); $document.write ("Age: +person.age+" <br/> "); $document.write ("Gender:" +person.sex+ "<br/>"); - person.eat (); -document.write ("<br/>"); the Person.run (); -document.write ("<br/>");Wuyidocument.write ("); the         varPerson={id: "10012", Name: "Xiao Zhao", age:24,sex: "Male", Eat:function(){ -document.write ("Eat (): All men and women like to eat well."); Wu},run:function(){ -document.write ("Run (): The male woman is all lazy yo!" So be conscious! "); About         }}; $document.write ("No.:" +person.id+ "<br/>"); -document.write ("Name:" +person.name+ "<br/>"); -document.write ("Age: +person.age+" <br/> "); -document.write ("Gender:" +person.sex+ "<br/>"); A person.eat (); +document.write ("<br/>"); the Person.run (); -document.write ("<br/>"); $</script> the      the</body> the

Learning and using JavaScript to create objects

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.