In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to convert one-dimensional array and two-dimensional array in JS". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to convert one-dimensional array and two-dimensional array in JS.
One-dimensional array to two-dimensional array arr1to2 (arr, number) {var arr2 = []; let len = arr.length; for (let I = 0, j = 0; I
< len; i += number, j++) { arr2[j] = arr.splice(0, number); } return arr2; }, 使用: let arr1 = [ 103.743896484375, 21.48374090716327, 101.05224609374999, 20.550508894195637, 103.60107421874999, 17.518344187852218 ]; console.log('一维数组:', arr1); let arr2 = this.arr1to2(arr1, 2); console.log('二维数组:', arr2);If the second parameter of arr1to2 is 3, the effect is as follows:
From a two-dimensional array to an one-dimensional array
/ / two-dimensional array to one-dimensional array let arr = [103.743896484375, 21.48374090716327], [101.05224609374999,20.5508894195637], [103.60107421874999,17.518344187852218]; console.log ('two-dimensional array:', arr); let newarr = []; for (const item of arr) {newarr = [. Newarr,... item] } console.log ('one-dimensional array:', newarr); at this point, I believe you have a better understanding of "how to convert one-dimensional array and two-dimensional array in JS". You might as well do it in practice! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.