zoukankan      html  css  js  c++  java
  • [Javascript] The Array map method

    One very common operation in programming is to iterate through an Array's contents, apply a function to each item, and create a new array containing the results. For example, let's say you wanted to loop through an array of stock objects and select only the name for display on screen. In this lesson we will demonstrate how to use the Array's map method to easily perform this operation with less code than a loop would require.

    function getStockSymbols(stocks) {
      return stocks.map(function(stock) {
        return stock.symbol;
      })
    }
    
    var symbols = getStockSymbols([
      { symbol: "XFX", price: 240.22, volume: 23432 },
      { symbol: "TNZ", price: 332.19, volume: 234 },
      { symbol: "JXJ", price: 120.22, volume: 5323 },
    ]);
    
    console.log(JSON.stringify(symbols));
  • 相关阅读:
    cf #363 c
    cf #363 b
    cf #363 a
    跑rbgirshick的fast-rcnn代码
    改文件夹名称
    cmake安装
    argparse模块
    which,whereis,locate,find
    FastRCNN 训练自己数据集 (1编译配置)
    视觉一般的面试问题
  • 原文地址:https://www.cnblogs.com/Answer1215/p/4356381.html
Copyright © 2011-2022 走看看