Analysis of MySQL PHP Grammar
- 2021-11-13 18:36:52
- OfStack
Let's first look at the basic syntax of charAt function under 1
character = str. charAt (index)
The only 1 argument to the charAt function is index in the string, from which a single character is extracted. This index ranges between 0 and length-1, including restrictions. If no index is specified, the first character of the string is returned because 0 is the default index used for this function.
The function returns a single character at the index specified as the function parameter. If the index is out of range, this function returns an empty string.
Let's take a look at a concrete example of the charAt function
The code is as follows
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script>
function func() {
var str = 'JavaScript is object oriented language';
var value = str.charAt(9);
document.write(value);
}
func();
</script>
</body>
</html>
The output is as follows: t
The above content is very simple, thank you for reading and supporting this site.