Using Plunker, How to access variable from the browser console

Mike Barlow - BarDev picture Mike Barlow - BarDev · Jul 16, 2013 · Viewed 14.6k times · Source

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>

Answer

Mike Barlow - BarDev picture Mike Barlow - BarDev · Jul 16, 2013

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?