Javascript - Apply trim function to each string in an array

后端 未结 11 1333
-上瘾入骨i
-上瘾入骨i 2020-12-07 14:22

Want to trim each string in an array, e.g., given

x = [\' aa \', \' bb \'];

output

[\'aa\', \'bb\']

My fi

11条回答
  •  时光取名叫无心
    2020-12-07 14:59

    If you are using JQuery, then a better way to do this, as it will work with IE8 as well (I need to support IE8) is this:

    $.map([' aa ', ' bb ', '   cc '], $.trim);
    

提交回复
热议问题