此方法返回字符串的面向调试版本,即用单引号或双引号引起来,反斜杠和引号被转义。
语法
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>
作者:terry,如若转载,请注明出处:https://www.web176.com/prototype_api/8871.html