美文网首页
Sorted by the new coming and the

Sorted by the new coming and the

作者: yilinUnique | 来源:发表于2019-10-29 14:38 被阅读0次
    var sortedArr = [];
    function getSortedArray(obj) {
      var existIndex = -1;
      sortedArr.forEach(function(e, i) {
        if (e.id === obj.id) {
          existIndex = i;
        }
      });
      if (existIndex >= 0) {
        var a = sortedArr.slice(0, existIndex);
        a.unshift(obj);
        sortedArr = a.concat(sortedArr.slice(existIndex + 1));
      } else {
        sortedArr.unshift(obj);
      }
      return sortedArr;
    }
    
    sorted.png

    相关文章

      网友评论

          本文标题:Sorted by the new coming and the

          本文链接:https://www.haomeiwen.com/subject/uctgvctx.html