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"}]
  • 相关阅读:
    生成函数代替伯努利数
    关于费用流
    GDOI注意事项
    计算几何 学习笔记
    jzoj5370
    图上的游戏
    小学生语文题
    arcane
    P2305 [NOI2014] 购票
    P3512 [POI2010]PIL-Pilots
  • 原文地址:https://www.cnblogs.com/guozongzhang/p/10942810.html
Copyright © 2011-2022 走看看