xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

js map & Number & trim All In One

js map & Number & trim All In One

js map & Number

Array

const regionIds = `1,2,3`;
// "1,2,3"

regionIds.split(',').map(Number);
// (3) [1, 2, 3]

trim

const nums = `
 111 ,
 222 ,
 333,
`;

nums.split(',').map(item => item.trim()).filter(str => str.length);
// (3) ['111', '222', '333']

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim

refs

https://www.cnblogs.com/xgqfrms/p/16015408.html



©xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


refs



©xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


posted @ 2021-01-21 15:23  xgqfrms  阅读(111)  评论(1编辑  收藏  举报