JavaScript Primer Basics Manual (1/6)

Source: Internet
Author: User

1.
Using the properties of a variable
<script type= "text/web Effects" >
var txt= "Hello world!"
document.write (Txt.length)
</script>


2.
Converts all letters in a string to uppercase letters.
<script type= "Text/javascript" >
var str= "Hello world!"
document.write (Str.touppercase ())
</script>


3.
JS in a variable to add a hyperlink
<script type= "Text/javascript" >
var txt= "Hello world!"
document.write ("<p> hyperlink is:" + txt.link ("http://www.w3school.com.cn") + "</p>")
</script>

4.
The IndexOf method, where the first occurrence of a specified character in a string is positioned. If you do not find the return-1, case-sensitive
<script type= "Text/javascript" >
var str= "Hello world!"
document.write (Str.indexof ("hello") + "<br/>")//1
document.write (Str.indexof ("World") + "<br/>")//-1
document.write (Str.indexof ("World"))//6
</script>

5.
Match () method
Use Match () to find a specific character in the string and, if found, return the character.
<script type= "Text/javascript" >
var str= "Hello world!"
document.write (Str.match ("World") + "<br/>")//world
document.write (Str.match ("World") + "<br/>")//null
document.write (Str.match ("worlld") + "<br/>")//null
document.write (Str.match ("world!"))//world!
</script>

Home 1 2 3 4 5 6 last
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.