Javascript array reverse function unexpected behavior

后端 未结 8 2046
执念已碎
执念已碎 2021-01-03 05:10

I would like to understand why situation 1 and situation 2 don\'t return the same results.

Situation 1 :

var array1 = [\"1\", \"2\", \"3\"];
var arra         


        
8条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-03 06:11

    The reverse method transposes the elements of the calling array object in place, mutating the array, and returning a reference to the array. Thus, it does not return the reversed array.

    CHECK the manuel. https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse

提交回复
热议问题