Print Var in JsFiddle
⚡TLDR
Quickly display a variable in JsFiddle using the snippet:
- Use console.log()to unleash your variable to the console.
- Assign the variable to document.body.textContentfor a visual treat on your webpage.
For an augmented debugging experience and console functionality in JSFiddle, try Firebug Lite:
- Graft-as-an-external resource: https://getfirebug.com/firebug-lite-debug.js
- Empower your JSFiddle with in-pane console capabilities similar to your browser's developer tools.
Advanced Variable Printing Techniques
Crafting HTML console simulation
To create a custom console-like output box in your fiddle:
Command output with jQuery
For the jQuery enthusiasts out there:
There you have it! A neat and clean output without ever risk-touching document.write().
Traps & Troubleshooting
Keep a lookout for:
- The Document.write menace: A double-edged sword that can wipe out your HTML.
- The Invisible output syndrome: Style controls visibility. Your output might be there, just not visible.
- The Sea of logs: Too many log messages is to a sailor lost at sea without a compass.
Serving multiple orders
Want to print multiple variables or an array? We got you:
Resorting to the browser console
Your browser's console is pretty much your all-weather friend. In Chrome, hit CTRL + SHIFT + J to awaken the beast.
Linked
Was this article helpful?
