Watch and Code       Subscribe       RSS

Accessing Plunker JavaScript variables in the console

Edit: Can’t believe that Plunker retweeted this post!


I really love Plunker. It’s perfect for testing quick snippets of code. But it took me a while to figure out how to get access to my JavaScript inside of the console. Usually in the console, you can print out values in your JavaScript, but that doesn’t work by default with Plunker.

For example, below, I’m defining a variable, myName and then I’m trying to access it in my console, but it’s undefined.

GIF showing how Plunker JavaScript variables are inaccessible from the console

After playing around a little bit with the console, I figured out that you can easily fix this by just changing the the context from <top frame> to plunkerPreviewTarget(run.plnkr.co/).

GIF showing how Plunker JavaScript variables are inaccessible from the console


If you want to learn how to build real software with JavaScript, you should sign up for Practical JavaScript.