Prototype - inspect() Method


Advertisements


This method returns a debug-oriented version of the string, i.e., wrapped in single or double quotes, with backslashes and quotes escaped.

Syntax

string.inspect([useDoubleQuotes = false]);

Return Value

Returns a debug-oriented version of the string.

Example

<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>

Output


prototype_string_processing.htm

Advertisements