2019-07-09

lucky_ss發表於2019-07-09

split()字串分割成字串陣列

var str="How are you doing today?"
document.write(str.split(" ") + "<br />")
document.write(str.split("") + "<br />")
document.write(str.split(" ",3))

2019-07-09

reverse()方法用於顛倒陣列中元素的順序

    var arr=['how','are','you'];
    document.write(arr.reverse())

輸出:

       you,are,how

join()把陣列中的所有元素放入一個字串

   var arr=['how','are','you'];
    document.write(arr.join()+'<br/>')
    document.write(arr.join(''))

輸出:

how,are,you
howareyou

The sun is always behind the storm~