Js must-have built-in objects, built-in objects are ECMAscript standards and well-defined standard objects that have been implemented by browser vendors. Built-in objects encapsulate special APIs for data and operation data.
There are ten built-in object lists in JavaScript, which are:
String, Boolean, Number, Array, Data, Math, Error, FuncTIon, Object, Global
Wrapper types String, Number, Boolean: Data that encapsulates the original type and provides built-in objects for common operations on the data.
Why? Because you want the raw type of data to be the same as the reference type, owning methods and properties. When do you use the wrapper type? As long as the method is called with the original type of data or when accessing the property, the js engine will automatically create the corresponding wrapper type object. After the method is called, the wrapper type object will be automatically released.

String object is used to process text strings

Create a primitive type string variable
Var stuName='Smith' //Direct reference
Var gender='male'; //direct reference
Var priceString=String(150.5); //Conversion type Create a reference type string object:
Var carType=New String('bmw528LI');//created by myself because of the addition of New
String wrapper type
Str.length: Returns the number of characters in the str string.
The str.toLowerCase() method returns the full lowercase format of the string.
The str.toUpperCase() method returns the fully capitalized form of the string
Var str="Hello,World";
Str=str.toLowerCase();
Str1=str.toUpperCase();
Document.write(str+str1);
Output hello, world HELLO, WORLD Note that the conversion must be received with one character. If it is not received, the parameters cannot be modified. Once created, it cannot be modified. You cannot modify the meta string. If you modify it, you must create a new one. String, then replace the result, save the new value, as long as the string api is called, you must use the new variable to receive the return value string. You must remember that the interview must test the string API; the underlying string is the character implementation. of
Var a='hello';
Console.log(a.length);//Output 5 5 characters Returns the character at the specified position: var char=str.charAt(index); //char in the index position, character Enter the ID number to output the gender
Var pid="371471194710040056";
Var char=pid.charAt(pid.length-2);
Console.log(char%2==0?"Female": "Men");
Encoding and transcoding Uncode
Input=prompt("Please enter the one that needs to be converted");
Var result=[];
For(var i=0;i result.push(input.charCodeAt(i));
}
Document.write("The character you typed: "+input+"---"+" converted character: "+result.join(""));
5 digits when converting, less than 5 digits with 00000
Input=prompt("Please enter the one that needs to be converted");
Var result=[];
For(var i=0;i var num=input.charCodeAt(i);
If(num<10000){//less than five are all five
Var arr=[0,0,0,0,0];
Var code=num+""; //Convert num to String
Var start=5-code.length;
For(var n=0;n arr[start]=code[n];
Start++;
}
Num=arr.join("");
}
Result.push(num);
}
Document.write("The character you typed: "+input+"---"+" converted character: "+result.join(""));


5 digits when converting, less than 5 digits with 00000, plus decoding
Input=prompt("Please enter the one that needs to be converted");
Var result=[];
For(var i=0;i var num=input.charCodeAt(i);
If(num<10000){//less than five are all five
Var arr=[0,0,0,0,0];
Var code=num+""; //Convert num to String
Var start=5-code.length;
For(var n=0;n arr[start]=code[n];
Start++;
}
Num=arr.join("");
}
Result.push(num);
Var c;
c=result.join("");
}
Document.write("The character you entered: "+input+"---"+" converted character: "+c);
Var b=[];
For(var i=0;i var code=c.substring(i,i+5);//Intercept five
B.push(String.fromCharCode(code));//Push operation
}
Var d=b.join("");
Document.write("
Converted string: "+d);


Split the string according to the law. The key interview will use the new string after the split, otherwise it can't be used.


String optimization law Frequently for strings +=, use array instead! ! ! ! And its important
Step1: put each substring into an array
Step2:join("") splicing array primaries with +"" is the most efficient way to connect empty strings. It is more efficient than the toString method. The three operating rules of the string are 1. Find the keyword 2 and replace the key 3. Get substring
1, the search keyword returns the location of the keyword, otherwise it is -1
Var index=str.indexOf("keyword"); Always find only one keyword. The default can only be overloaded from 0: var index=str.indexOf("keyword", from); from the position to start searching ;
Var str="Today is very happy Friday on Friday";
Var index=str.indexOf("Friday");
Console.log("Location:"+index+"Found keyword");
Var index=str.indexOf("Friday", index+1);
Console.log("Location:"+index+"Found keyword");
Output: Location: 3 found keywords Location: 10 found keywords Optimization: indexOf () are using the following routines must remember
Var str="Today is very happy Friday on Friday";
Var index=-1;
While((index=str.indexOf("Friday", index+1))!=-1){ //index+1 means starting from the last found position, continue to the next
Console.log("Location"+index+"Found keyword");
}
Remarks: var index=str.lasTIndexOf("keyword", from); is looking from the back to the front var index=str.IndexOf("keyword", from); is looking from the front to the back


Var str="Today is very happy Friday on Friday";
Var index=str.length;
While((index=str.lasTIndexOf("Friday", index-1))!=-1){ //index+1 means starting from the last found position, continue to the next
Console.log("Location"+index+"Found keyword");
}
Strings are searched from the back to the front and need to be modified in two places.
1:index+1 becomes index-1 because it has been going backwards
2:var index=-1 becomes var index=str.length; because it is the maximum length from the interception of the string
Var subStr=str.slice(start,end); Include header without tails Usage is the same as substring (java language is substr, js is slice) The only difference is that slice does not support -1
If you omit the following characters, it will intercept all var str="345681994412270088";
Var subStr=str.slice(5,8+1);
Var subStr1=str.slice(-12-1,-9); //Start from the beginning document.write("Your birth year is "+subStr);
Document.write("Your birth year is "+subStr1);
Get the first letter of each letter and then capitalize
Var str="you can you up";
Var words=str.split(" "); //Start the split by " "
For(var i=0;i // take the first letter of each word
Words[i]=words[i][0].toUpperCase()+words[i].substr(1);//takes less than one element, the first letter at the beginning is capitalized
}
Str=words.join(" ");
Document.write(str);


Determine the number of a string: the number of returned numbers, the number of letters, the number of English according to your unicode range 48-57 is 0-9 is a numeric character
65-90 range of AZ
97-122 az is a lowercase letter
19968-40869 Range of Chinese characters
Var str="Buy AppleCare+, extended warranty for 2 years";
Var engCount=0;
Var numCount=0;
Var chsCount=0;
Var other=0;
Var num1=str.charCodeAt();
For(var i=0;i var num=str.charCodeAt(i);
If(num>=19968&&num<=40869){
chsCount++;
}else if((num>=65&&num<=90)||(num>=97&&num<=122)){
engCount++;
}else if(num>=48&&num<=57){
numCount++;
}else{
Other++;
}
}
Document.write("The original character is: "+str+
"
Converted to Unicode encoding is: "+num1+
"
Chinese characters are: "+chsCount+
"
The English character is: "+engCount+
"
The number is: "+numCount+
"
The other is: "+other";
Pattern matching: You can set the rules for finding or when to replace the rules when using pattern matching: the keywords to be searched may change regularly. How to use pattern matching: 1, first define the pattern: / keyword / mode, pay attention to not double quotation marks
Var reg=/no/i; no is the element to be found, i means ignore case, g means global action can be used in Chinese
In the String type, an API that specifically supports pattern matching is provided.
Replace keywords by pattern: str=str.replace(reg,"new value"); variables must be passed back
Var str="No zuo no die";
Var reg=/no/ig; //add i to ignore case, if not, match lowercase, g replace all
Str=str.replace(reg,"yes");
Document.write(str);
Match the match(value/regexp) method to retrieve the specified value within the string, or find one or more substrings that match the regular expression. In any case, if it is an array, add s
The place of the defect: you can return the keyword, but you can't see the address. If it is not found, it returns null.
Var str="No zuo no die";
Var reg=/no/ig; //add i to ignore case, if not, match lowercase, g replace all
Var kwords=str.match(reg);
If(kwords!="null"){//Because if the search variable does not, it will be returned empty, and if it may appear null in the future, it will be judged in advance.
Document.write(kwords); //output No, no
Document.write("replaces "+kwords.length+"");
}
Find str.searh();
Same as indexOf, but does not support pattern lookup
Var index=str.search(reg) is exactly the same as indexOf
Search is the pattern lookup version of indexOf regular expression
Why? The law of the occurrence of characters in a string. Role: verify string format, find keywords, replace keywords
1, select the symbol: [so alternative characters]
A [] can only represent one type of character
1[123] means 12,11,13
1[^123] means 1 and except 123
- symbol, the continuous range of candidate characters [1-9] means 1-9
[a-zA-Z0-9]->\w alphanumeric matching
[0-9]->\d Match number Null character /s
The two occurrences of the character {min,max} num are the fixed length min minimum length, max maximum length; i++){
;i++){
;i+=5){ >;n++){
;n++){

KW3-Special Function Micro Switch

✿Special Function

-High Current Micro Switch

-Light force Micro Switch

-High&Low Pressure Switch

-3mm Contact Clearence Micro Switch

-Tubular Motor Switch



✿ Material

Made of high quality plastic and metal, rust resistance and corrosion resistance, durable enough for you to hanging items, So the product appearance is exquisite, perfect workmanship.

✿ Rating

You can meet the different RATING daily needs. Please pay attention to the model of the switch before purchase, to ensure that you purchase the same as you need.

✿ Vairous Sizes

Actuator Action is momentary and Actuator Type is long straight hinge lever. Switch Body Size as shown in the picture.So different sizes can meet all your daily different needs.

✿ Wide Application

Home appliance: micro oven, electric cooker, washing machine, electric heater, warmer, water fountain and so on.

Commercial appliance: Vending machine, electric toy, electric tools, duplicating machine and so on.

Machinery: Transport machinery, printing machinery, textile machinery and so on.

Small Micro Switch,Micro On Off Switch,Micro Limit Switch Types,Special Function Micro Switch

Ningbo Jialin Electronics Co.,Ltd , https://www.donghai-switch.com

Posted on