Question

I'm using Plunker (http://plnkr.co/) to test JavaScript. From the browser console I want to access variables that I defined in the script.

In Plunker, can anyone tell me how to access the variable "someValue" from the browser console.

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <script type="text/javascript">
      var someValue = 3
      console.log(someValue);
    </script>
</body>
</html>
Était-ce utile?

La solution

I figured out one possible solution. In Google Chrome's Developer Tools on the bottom of the developer console "top frame" can be changed to "run.plnkr.co" (see image below). This will change the scope of the console and the variables in the script can now be accessed.

Plunker in Google Chrome

Here's the answer for jsFiddle: Access variables in jsFiddle from Javascript console?

Autres conseils

or you can use http://jsbin.com/ which displays the console directly

using a separate window helped me debug the scopes and everything.

just follow as below, and then use F12

expand to a seperate window

Try to use console.debug( variable );

Take a look in this post as well:

Difference between console.log() and console.debug()?

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top