你的位置:首页 > 软件开发 > Java > JavaScript 数组方法处理字符串 prototype

JavaScript 数组方法处理字符串 prototype

发布时间:2017-11-23 12:06:03
js中数组有许多方法,如join、map,reverse。字符串没有这些方法,可以“借用”数组的方法来处理字符串。<!doctype html><html lang="en"> <head& ...

js中数组有许多方法,如join、map,reverse。字符串没有这些方法,可以“借用”数组的方法来处理字符串。

<!doctype html><html lang="en"> <head>  <meta charset="UTF-8" />  <title>JavaScript 数组方法处理字符串</title> </head> <body>  <script type="text/javascript">   //定义数组   var a = [1, 2, 3];   //数组的处理方法   console.log(a.join('-'));   //定义字符串   var b = 'abc';   console.log(Array.prototype.join.call(b, '-'));  </script> </body></html>

 

 

海外公司注册、海外银行开户、跨境平台代入驻、VAT、EPR等知识和在线办理:https://www.xlkjsw.com

原标题:JavaScript 数组方法处理字符串 prototype

关键词:JavaScript

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。