In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "how to use String objects in JavaScript". In daily operation, I believe many people have doubts about how to use String objects in JavaScript. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts about "how to use String objects in JavaScript". Next, please follow the editor to study!
Overview of methods:
Instance (free conversion between strings and string objects in js, strings can directly use the methods and properties of string objects):
Var ss= "Sun Shibin Ni Weihao Tang Jian Ni Weihao"; [xss_clean] (ss.anchor ("cc") + "
Generate a HTML code: sun Shibin Ni Weihao Tang key Ni Weihao [xss_clean] (ss.link ("https://www.bilibili.com/")+")
"); / / generate a HTML code:
< a href="https://www.bilibili.com/">Sun Shibin Ni Weihao Tang Jian Ni Weihao [xss_clean] (ss.big () + "
Generate a HTML code: sun Shibin Ni Weihao Tang key Ni Weihao [xss_clean] (ss.small () + "
Generate a HTML code: sun Shibin Ni Weihao Tang key Ni Weihao [xss_clean] (ss.blink () + "
Generate a HTML code: sun Shibin Ni Weihao Tang key Ni Weihao [xss_clean] (ss.bold () + "
Generate a HTML code: sun Shibin Ni Weihao Tang key Ni Weihao [xss_clean] (ss.charAt (0) + "
"); / / gets the 0th character in ss, starting with 0; output: sun [xss_clean] (ss.charCodeAt (0) +"
"); / / get the Unicode code of the 0th character in ss, output: 23385 [xss_clean] (ss.concat (" old friend ") +"
Concatenate the string "old friend" into the string ss and output: sun Shibin Ni Weihao Tang key Ni Weihao old friend [xss_clean] (ss.fontcolor ("red") + "
Generate a HTML code: sun Shibin Ni Weihao Tang key Ni Weihao [xss_clean] (ss.fontsize (1) + "
Generate a HTML code: sun Shibin Ni Weihao Tang key Ni Weihao [xss_clean] (ss.strike () + "
Generate a HTML code: sun Shibin Ni Weihao Tang key Ni Weihao [xss_clean] (ss.sub () + "
"); / / generate a HTML code: JavaScript tutorial [xss_clean] (ss.italics () +"
Generate a HTML code: sun Shibin Ni Weihao Tang key Ni Weihao [xss_clean] (ss.sup () + "
Generate a HTML code: sun Shibin Ni Weihao Tang key Ni Weihao [xss_clean] (ss.indexOf ("Ni Weihao") + "
"); / / get the position of the string" Ni Weihao "that first appears in ss, and output: 3 [xss_clean] (ss.lastIndexOf (" Ni Weihao ") +"
); / / get the last occurrence of the string "Ni Weihao" in ss, and output: 8 [xss_clean] (ss.localeCompare ("ww") + "
Compare the string object with the given string and return:-1 [xss_clean] (ss.match (/ / Ni] / g) + "
"); / / retrieve ss according to regular / [Ni] / g. Return: ni, if Ni is not regular, it will only match 1 character [xss_clean] (ss.replace (/ [Ni] / g," ni ") +".
Replace regular / [Ni] / g matching characters with the string "ni". Return: sun Shibin ni Weihao Tang key ni Weihao [xss_clean] (ss.search (/ [Ni] / g) + "
"); / / gets the first occurrence position of the string that matches the rule, and returns: 3 [xss_clean] (ss.slice (0Jing 3) +"
"); / / intercept the string (get the 0 to 2 characters in str), and return: sun Shibin [xss_clean] (ss.split (" Ni ") +"
Split the string str into arrays according to "Ni". Return: sun Shibin, Weihao Tang key, Weihao [xss_clean] (ss.substr (0jue 3) + "
"); / / start with the 4th character, intercept 3 characters backwards, and return: sun Shibin [xss_clean] (ss.substring (3jue 6) +"
"); / / intercept the string (get the 3rd to 5th characters in the str), and return: ni Weihao [xss_clean] (String.fromCharCode (72jue 66je 76jue 79) +"
"); / / convert Unicode encoding to specific characters, output: HELLO
Html runs through tags containing external js files
Love
At this point, the study on "how to use String objects in JavaScript" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.