zoukankan      html  css  js  c++  java
  • 下划线连接字符串变驼峰连接

    var arr = [
      'so_no_item',
      'soid',
      'original_part_no',
      'quantity',
      'uom',
      'status',
      'delivery_block',
      'part_description',
      'internal_status',
      'default_warehouse',
      'default_location',
    ]
    arr = arr.map(value => {
      let str = value.split('_')
      let newValue = str[0]
      str.forEach((item,index) => {
        str[index] = str[index].substring(0,1).toUpperCase() +  str[index].substring(1)
        if (index>0) {
          newValue += str[index].substring(0,1).toUpperCase() + str[index].substring(1)
        }
      })
      return {
        name: str.join(' '), 
         160, 
        isShow: true,
        value: newValue
      }
    })
    console.log(JSON.stringify(arr))


    [{"name":"So No Item","width":160,"isShow":true,"value":"soNoItem"},{"name":"Soid","width":160,"isShow":true,"value":"soid"},{"name":"Original Part No","width":160,"isShow":true,"value":"originalPartNo"},{"name":"Quantity","width":160,"isShow":true,"value":"quantity"},{"name":"Uom","width":160,"isShow":true,"value":"uom"},{"name":"Status","width":160,"isShow":true,"value":"status"},{"name":"Delivery Block","width":160,"isShow":true,"value":"deliveryBlock"},{"name":"Part Description","width":160,"isShow":true,"value":"partDescription"},{"name":"Internal Status","width":160,"isShow":true,"value":"internalStatus"},{"name":"Default Warehouse","width":160,"isShow":true,"value":"defaultWarehouse"},{"name":"Default Location","width":160,"isShow":true,"value":"defaultLocation"}]
  • 相关阅读:
    Jzoj4782 Math
    Jzoj4778 数列编辑器
    Jzoj4778 数列编辑器
    力扣算法题—067二进制求和
    力扣算法题—066加一
    最小凸包算法
    力扣算法题—065有效数字
    力扣算法题—064最小路径之和
    力扣算法题—063不同路径2
    力扣算法题—062不同路径
  • 原文地址:https://www.cnblogs.com/guozongzhang/p/10942810.html
Copyright © 2011-2022 走看看