JavascriptcharAt () gets the character at the specified position of the string

Source: Internet
Author: User
In js, if you want to obtain a character at the specified position of a string, you can use the charAt () function to obtain the character. We only need to pass the index at the specified position into the charAt () function to obtain the result. This article describes the basic syntax of the charAt () function and its examples. For more information about the coders, see. The charAt method returns the characters at the specified index position.

Basic syntax

StrObj. charAt (index)

Parameter Introduction

Parameters Description
Index Required. Returns the zero-based index of the expected characters. The valid value is the value between 0 and the string length minus 1.

Description

The charAt method returns a character value at the specified index position. The index of the first character in the string is 0, the index of the second character is 1, and so on. If the index value exceeds the valid range, an empty string is returned.

Instance:

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.