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
JS--Object