Connection and interception of JavaScript strings

Source: Internet
Author: User

1 <!DOCTYPE HTML>2 <HTMLLang= "en">3 <Head>4     <MetaCharSet= "UTF-8">5     <title>Document</title>6 </Head>7 <Body>8     <Script>9         //concat (): Connect two strings to return a new string and will not be modifiedTen         varstr1= "Hello"; One         varstr2= "123"; A         varSTR3=Str1.concat (str2); - Console.log (str1); - Console.log (str2); the Console.log (STR3); -  -         varStr= "I Love my family!"; - Console.log (str); +         //Slice (): intercepts a string based on index value and index value - Console.log (Str.slice (2)); //intercept from index to last + Console.log (Str.slice (2,5)); //intercept from index, package left not packet right A Console.log (Str.slice (-3)); //A couple of Countdown at Console.log (Str.slice (5,3)); //empty string -  -         //substr (): Intercept string based on index value and length - Console.log (Str.substr (2)); //intercept from index to last - Console.log (Str.substr (2,6)); //Intercept ~ length strings from an index - Console.log (Str.substr (-3)); //A couple of Countdown in  -         //substring (): Intercepting strings based on index and index values to Console.log (str.substring (2)); //intercept from index to last + Console.log (str.substring (2,5)); //Intercept ~ length strings from an index - Console.log (str.substring (-1)); //Intercept All the Console.log (str.substring (5,2)); //can only Exchange *     </Script> $ </Body>Panax Notoginseng </HTML>

Connection and interception of JavaScript strings

Related Article

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.