Source: Internet
Author: User

One: Three ways to create objects

//Method OnePeople =NewObject (); People.name= "Wyp"; People.age= "22"; document.write ("Name:" + People.name + ", Age:" +people.age); //Method Twoperson ={name:"Wyp", Age:"22"        }; document.write (Person.name+person.age); //method Three uses a function to create an object        functionp (name, age) { This. Name =name;  This. Age =Age ; } p1=NewP ("Wyp", 22); document.write (P1.name+ p1.age);//Output Wyp22

Two: String Object

        //String String Object        varstr = "Hello World"; document.write (str.length); //output one by one        //IndexOf finding the position of a string in a string exists in the position returned in the stringdocument.write (Str.indexof ("World"));//Output 6document.write (Str.indexof ("T"));//returns-1        //content Match matchdocument.write (Str.match ("World"));//Print out worlddocument.write (Str.match ("1"));//Print out null        //Replace string substitutiondocument.write (Str.replace ("World", "WYP")); //string Case Conversion touppercase () toLowerCase        //Split        varstr1 = "Hello|world"; varS1 = str1.split ("|"); document.write (s1[0]);//Output Hello


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.