JS Getting Started Tutorial: JavaScript string Object

Source: Internet
Author: User

JavaScript String Object

Let's take a look at an instance of the length of the returned character.

<body>

<script type= "Text/javascript" >

var txt= "Hello world!";
document.write (txt.length);

</script>

</body>

Result is 12

Let's look at an example.

The IndexOf () method
How to use the IndexOf () method to return the position of the first occurrence of the specified string value.
<body>

<script type= "Text/javascript" >

var str= "Hello world!";
document.write (Str.indexof ("Hello") + "<br/>");
document.write (Str.indexof ("World") + "<br/>");
document.write (Str.indexof ("World"));

</script>

</body>

Okay, let's take a look at a simple introductory tutorial on JavaScript string pairs.

Full string Object range
For a complete reference of all the properties and methods that can be used with a string object, please give us a full range of string objects.

Mention contains a short description and examples of each of the properties and methods used!

String Object
Stores a piece of text.

Use Example:

The following example uses a string object of length property to find the length strings:

var txt= "Hello world!";
document.write (txt.length);
Output Results 12
The string object is used to control a string object that uses the toUpperCase () method to convert strings to uppercase letters: var txt= "Hello world!";
document.write (Txt.touppercase ());

Output for big Hello world!

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.