js内建函数

  • Object.keys()
    var a = {a:1, b:2, c:3};
    var b = Object.keys(a); //["a", "b", "c"]
  • Object.values()
    var a = {a:1, b:2, c:3};
    var b = Object.values(a); //[1, 2, 3]
  • [].map()
    var a = [1, 2, 3, 4, 5, 6];
    var b = a.map(function (item) {
    return item + 10;
    }); //[11, 12, 13, 14, 15, 16]
  • [].filter()
    var a = [1, 2, 3, 4, 5, 6];
    var b = a.filter(function (item) {
    if (item % 2 === 1) {
    return true;
    }
    }); // [1, 3, 5]

你可能感兴趣的:(js内建函数)