Get the last item in an array

前端 未结 30 3365
执念已碎
执念已碎 2020-11-22 05:28

Here is my JavaScript code so far:

var linkElement = document.getElementById(\"BackButton\");
var loc_array = document.location.href.split(\'/\');
var newT =         


        
30条回答
  •  面向向阳花
    2020-11-22 06:05

    Not implemented yet!

    The new TC39 Array.prototype.lastItem proposal (stage 1) adds a getter that returns the last item in an array:

    const myArray = [1, 2, 3]
    
    console.log(myArray.lastItem)
    //=> 3
    

    The Array.prototype.item proposal (stage 3) adds a different API:

    const myArray = [1, 2, 3]
    
    console.log(myArray.item(-1))
    //=> 3
    

提交回复
热议问题