Tutorials Point

  Learn Prototype
  Prototype Resources
  Selected Reading

Copyright © 2014 by tutorialspoint

  Home     References     Discussion Forums     About TP  

Prototype inspect() Method

previous next AddThis Social Bookmark Button


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


string.inspect([useDoubleQuotes = false]);

Return Value:

  • Returns a debug-oriented version of the string.


<title>Prototype examples</title>
<script type="text/javascript" 

function showResult(){

  var str = 'I\'m so happy.';

  alert( "Check without inspect :" + str ); 
  alert( "First Check :" + str.inspect() );
  alert( "Second Check :" + str.inspect( true ) );




  <p>Click the button to see the result.</p>
  <br />
  <br />
  <input type="button" value="Result" onclick="showResult();"/>


This returns the following value in actual but it will return different values in alert dialog or the console.

Check without inspect: I'm so happy.
First Check : '\'I\\\'m so happy.\''
Second Check : '"I'm so happy."'

To understand it in better way you can Try it yourself.

previous next Printer Friendly