Chrome Developer Tools: JS Interpreter?
-
25-09-2019 - |
Question
Sorry if I missed something and this is a silly question...but can I enter arbitrary javascript in the developer tools console (like I can with firebug)? It seems that I can interact with the DOM, console.log, etc., but I'm wondering if there's a way to enter code in to try things out like one would do with an interpreter?
EDIT:
So I was thrown because of the undefined return when I did a simple declaration and assignment, but yeah, it DOES work as a simple shell as I asked:
var i = 123;
undefined
console.log(i);
123
undefined
for(var j = 0; j < 10; j++) {
SyntaxError: Unexpected end of input
for(var j = 0; j < 10; j++) { console.log(j); }
0
1
2
3
My bad!
Solution
You can interact with the environment of the current page. You can then try out some code in a 'command-line' kind of way. Do post a feature request if you want more functionality.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow