js将字符串内空格去除的方法
function noSpace(x){ if(x.match(/\s*/g)){ return x.replace(/\s*/g,""); }else{ return x; } }
---
function noSpace(x){ return x.replace(/\s/g, ''); }
---
function noSpace(x){ var result = "" for(var index = 0; index < x.length; index++){ if(x[index] !== " "){ result += x[index]; } } return result; }
---
function noSpace(x){ return x.replace(/ /g,'') }
---
function noSpace(x){ return x.split("") .map(function(val){ return val == " "?"":val }) .join(""); }
本文来自博客园,作者:ukyo--君君小时候,转载请注明原文链接:https://www.cnblogs.com/ukzq/p/12033166.html