i have a a data model like this:
[#hello, #world, #foo, #bar]
I want to loop through each one of them and remove the number symbol, How di i go about his?
答案 0 :(得分:4)
Loop over the Array with your favourite method (e.g. arr.map
) and use str.slice(1)
['#hello', '#world', '#foo', '#bar'].map(function (e) {
return e.slice(1);
}); // ["hello", "world", "foo", "bar"]
答案 1 :(得分:0)
you can loop through each string of the array and perform a operation.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr