此方法逐个字符地拆分字符串并返回包含结果的数组。
语法
string.toArray() ;
返回值
返回字符数组。
例子
<html> <head> <title>Prototype examples</title> <script type = "text/javascript" src = "/javascript/prototype.js"> </script> <script> function showResult() { var str = "a"; alert("a.toArray() : " + str.toArray()[0] ); var str = "hello world!"; var arr = str.toArray(); arr.each(function(alpha) { alert(alpha); }); } </script> </head> <body> <p>Click the button to see the result.</p> <br /> <br /> <input type = "button" value = "Result" onclick = "showResult();"/> </body> </html> 输出
作者:terry,如若转载,请注明出处:https://www.web176.com/prototype_api/8822.html