原型 - inspect() 方法
此方法返回字符串的调试版本,即由单引号或双引号包裹起来,并转义反斜杠和引号。
语法
string.inspect([useDoubleQuotes = false]);
返回值
返回字符串的调试版本。
示例
<html> <head> <title>Prototype examples</title> <script type = "text/javascript" src = "/javascript/prototype.js"></script> <script> function showResult() { var str = 'I\'m so happy.'; alert( "Check without inspect :" + str ); alert( "First Check :" + str.inspect() ); alert( "Second Check :" + str.inspect( true ) ); } </script> </head> <body> <p>Click the button to see the result.</p> <br /> <br /> <input type = "button" value = "Result" onclick = "showResult();"/> </body> </html>
输出
prototype_string_processing.htm
广告