html javascript - array sort, reverse
function init() { const arr0 = ['car','bus','aircraft','spacecraft','car1','motorcycle','car'] const arr1 = [ {name: 'car', type: 'land', cost: 100}, {name: 'bus', type: 'land', cost: 50}, {name: 'aircraft', type: 'sky', cost: 200}, {name: 'motorcycle', type: 'land', cost: 80}, {name: 'spacecraft', type: 'space', cost: 1000} ] const arr2 = [5,3,21,6,50,100,1,10,12,20,..
html javascript - array concat
const arr0 = [1,2,3]const arr1 = [4,5,6]const arr2 = [7,8,9]const arr3 = arr0.concat(arr1, arr2)const arr4 = arr1.concat(arr2, arr0)const arr5 = arr0.concat(arr0, arr0)console.log(arr3) // [1,2,3,4,5,6,7,8,9]console.log(arr4) // [4,5,6,7,8,9,1,2,3]console.log(arr5) // [1,2,3,1,2,3,1,2,3]
html javascript - string split
const str0 = '123456789'const str1 = '1,2,3,4,5,6,7,8,9'const str2 = '1/2/3/4/5/6/7/8/9'const split0 = str0.split('')const split1 = str1.split(',')const split2 = str2.split('/')console.log(split0)console.log(split1)console.log(split2)// ["1","2","3","4","5","6","7","8","9"]
html javascript - array join
const arr = [1,2,3,4,5,6,7,8,9]const arrJoin0 = arr.join(',')const arrJoin1 = arr.join('/')let arrJoin2 = arr.join('won ') // 1won 2won 3won 4won 5won 6won 7won 8won 9arrJoin2 += 'won'const arrJoin3 = arr.join('')console.log(arrJoin0) // 1,2,3,4,5,6,7,8,9console.log(arrJoin1) // 1/2/3/4/5/6/7/8/9console.log(arrJoin2) // 1won 2won 3won 4won 5won 6won 7won 8won 9wonconsole.log(arrJoin3) // 123456789