I believe that many people who learn the JavaScript language will often be confused about the slice and splice methods. Although they have similar names, they have completely different functions. So this article will give you a detailed review of
Objective
Today I revisit the JavaScript, see the array method, there are two of the more similar methods--splice and splice, look like, is more than one P, but the usage is quite different.
In use, you can reduce confusion by selecting an API
The splice () method in JavaScript is a strong array method that has many uses.The main purpose of splice () is to insert items into the middle of the array.There are 3 ways of doing this:Delete--You can delete any number of items, just specify 2
from:http://www.jquerycn.cn/a_10447The splice () method in JavaScript is a strong array method that has many uses.The main purpose of splice () is to insert items into the middle of the array.There are 3 ways of doing this:Delete--You can delete any
The splice () method in JavaScript is a strong array method that has many uses.The main purpose of splice () is to insert items into the middle of the array.
There are 3 different ways:Delete-You can delete any number of items by specifying only 2
The substr () method extracts a specified number of characters starting with the start subscript from a string.StringObject. substr (start, length); start is required. length is optional.
Start is the subscript of the starting position of the
The substr () method extracts a specified number of characters starting with the start subscript from a string.
StringObject. substr (start, length); start is required. length is optional.
Start is the subscript of the starting position of the
ArticleDirectory
Syntax
Return Value
Description
Example 1
Example 2
Example 3
Splice, please note that splice is not a split, although the two looks very similar but not a thing.
Splice and not split can be used for
This article mainly introduces how to use slice (), splice (), split (), substring (), and substr () in javascript. For more information, see
1. slice ();
Both Array and String objects have
Slice (I, [j]) in Array
I is the index value that starts
This article mainly introduces how to use slice (), splice (), split (), substring (), and substr () in javascript. For more information, see
1. slice ();
Both Array and String objects have
Slice (I, [j]) in Array
I is the index value that starts
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.