zoukankan      html  css  js  c++  java
  • slice

    slice 方法 特性: arr.clice(start,end)

    • The original array will not be modified. 不改变原来的数组

    • index end is not included. 不包含end下标指向的元素

    • start :

      Zero-based index at which to start extraction.

      A negative index can be used, indicating an offset from the end of the sequence. slice(-2) extracts the last two elements in the sequence.

      If start is undefined, slice starts from the index 0.

    • end Optional

      Zero-based index before which to end extraction. slice extracts up to but not including end. For example, slice(1,4) extracts the second element through the fourth element (elements indexed 1, 2, and 3).

      A negative index can be used, indicating an offset from the end of the sequence. slice(2,-1) extracts the third element through the second-to-last element in the sequence.

      If end is omitted, slice extracts through the end of the sequence (arr.length).

      If end is greater than the length of the sequence, slice extracts through to the end of the sequence (arr.length).

    应用 将伪数组转为数组

    function list() {
      return Array.prototype.slice.call(arguments);
    }
    console.log(list(1,2,3,4,5,5)); // [1,2,3,4,5,5];
    
    慢慢来,比较快!基础要牢,根基要稳!向大佬致敬!
  • 相关阅读:
    vue嵌套路由
    不同的网络出现的报错
    yarn 创建react项目时出现错误
    vue-awsome-swiper竖向滚动出现空白
    SpringBoot路径映射
    ApplicationRunner接口
    CommandLineRunner接口
    springboot创建拦截器
    Cors跨域请求
    springboot自定义异常视图
  • 原文地址:https://www.cnblogs.com/rookie123/p/14245261.html
Copyright © 2011-2022 走看看