In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Today I'll show you how javascript gets the first few elements of the array. The content of the article is good. Now I would like to share it with you. Friends who feel in need can understand it. I hope it will be helpful to you. Let's read it along with the editor's ideas.
Javascript to get the first few elements of the array method: 1, use slice (), you can intercept a specified number of elements from the array, syntax "array.slice (0, number of elements)"; 2, use splice (), syntax "array.splice (0, number of elements);".
The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.
The method of getting the first few elements of an array by javascript
1. Use slice ()
The slice () method returns the selected element from an existing array.
The slice () method extracts a portion of a string and returns the extracted part as a new string.
Var fruits = ["Banana", "Orange", "Lemon", "Apple", "Mango"]; var citrus = fruits.slice (0J3); console.log ("first three elements of the array:" + citrus)
2. Use splice ()
The splice () method is used to add or remove elements from an array.
The splice () method returns an array of deleted elements.
Var fruits = ["Banana", "Orange", "Lemon", "Apple", "Mango"]; var citrus = fruits.splice (0Jing 2); console.log ("the first two elements of the array:" + citrus)
What is JavaScript? JavaScript is a literal scripting language whose interpreter is called JavaScript engine and is a part of the browser. JavaScript is a scripting language widely used on the client side. It was first used on HTML pages to add dynamic functions to HTML pages.
This is how javascript gets all the contents of the first few elements of the array. For more information about how javascript gets the first few elements of the array, you can search the previous articles or browse the following articles to learn! I believe the editor will add more knowledge to you. I hope you can support it!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.