zoukankan      html  css  js  c++  java
  • javascript常用方法,数组笔记 码农

    Array.from
    Array.from(arrayLike,[,mapFn[,thisArg]])

    Example
    1:Array.from({length: 5}).map((_,i)=>`slide ${i+1}`)

    ["slide 1", "slide 2", "slide 3", "slide 4", "slide 5"]


    Set
    Set 对象允许你存储任何类型的唯一值,无论是原始值或者是对象引用。

    let mySet = new Set();


    mySet.add(1); // Set [ 1 ]

    mySet.add(5); // Set [ 1, 5 ]

    mySet.add(5); // Set [ 1, 5 ]
    mySet.add('5'); // Set [ 1, 5,'5' ]
    mySet.add({a:1});


    apply
    apply() 方法调用一个具有给定this值的函数,以及以一个数组(或类数组对象)的形式提供的参数。
    func.apply(thisArg, [argsArray])

    const numbers = [5, 6, 2, 3, 7];
    const max = Math.max.apply(null, numbers);

    call 接受的是参数列表
    Math.max.call(null, 1,2,3);

    人生旅途,边走边看...
  • 相关阅读:
    前端工程师基础课程作业
    对于API接口设计的几点看法
    socket socket.io
    移动端布局
    angularJS
    bootstrop的应用
    jquery基础
    html5本地存储
    ajax
    数据库类型
  • 原文地址:https://www.cnblogs.com/dming4/p/15157883.html
Copyright © 2011-2022 走看看