Debugging JavaScript REPL-style?
Asked Answered
M

20

53

Is there any sort of interactive debugger for JavaScript? I'm imagining something like a web page on the left, and a REPL interface on the right.

Or maybe even without having a web page, so I can just play around with the JavaScript language.

Something that doesn't require I refresh the web page with breakpoints in Firebug or VS to examine locals and type code into a Watch window. Maybe I just need to learn Firebug better?

JavaScript doesn't have to be compiled, after all.

Kind of like LinqPad but for JavaScript maybe?

Anyone follow me here?

Means answered 16/3, 2009 at 10:49 Comment(3)
Old link, but since it comes up on Googe searches - JSFiddle.net is also a good option.Hillary
repl.it is a good place.Stokehole
Also, I jjust found babeljs.io/replStokehole
D
23

Stand-alone REPL (no browser/DOM, just JavaScript): JavaScript Shell from the Rhino project.

Dissection answered 16/3, 2009 at 11:3 Comment(2)
that link is a little confusing. I find it easier to just brew install rhino and then type rhino from the command prompt (OS X). Voila, you got the REPL.Evasion
@Ivanoats I saw no indication the OP was on OS X and using Homebrew, even if he should be ;-)Dissection
E
29

Node.js has a REPL.

On Mac OS X:

brew install node
node

.exit to exit the repl, .help for other options

http://nodejs.org/docs/v0.3.1/api/repl.html

Evasion answered 23/7, 2011 at 4:50 Comment(1)
And now there is UltraREPL - just saw it, going to give it a try today. github.com/Benvie/Node.js-Ultra-REPLEvasion
D
23

Stand-alone REPL (no browser/DOM, just JavaScript): JavaScript Shell from the Rhino project.

Dissection answered 16/3, 2009 at 11:3 Comment(2)
that link is a little confusing. I find it easier to just brew install rhino and then type rhino from the command prompt (OS X). Voila, you got the REPL.Evasion
@Ivanoats I saw no indication the OP was on OS X and using Homebrew, even if he should be ;-)Dissection
A
10

To me, the most convenient debugger and REPL for JavaScript is Mozrepl. It is a Firefox/XULRunner extension that accesses the browser/application instance using telnet, and you can observe and manipulate everything in the browser; even the browser itself (remember, always talking about Firefox).

It is amazingly useful as a debugger (on standalone XUL applications it is the only bearable way to do real debugging) and as a tool to play around and understand the guts of your application, it speeds up your Javascript development time tenfold.

For an impressive demo of is possibilities, check out this video.

Apposite answered 16/3, 2009 at 16:44 Comment(0)
B
9

eloquent javascript's console at the bottom of the page seems to what you are looking for. Just click on the console label and a sliding console will emerge.

To allow you to try out programs, both the examples and the code you write yourself, this book makes use of something called a console. If you are using a modern graphical browser (Internet Explorer version 6 or higher, Firefox 1.5 or higher, Opera 9 or higher, Safari 3 or higher), the pages in this book will show a bar at the bottom of your screen. You can open the console by clicking on the little arrow on the far right of this bar.

Birthplace answered 12/5, 2010 at 21:22 Comment(2)
+1 but note that it's a very thin bar at the bottom of the page - I nearly missed it even though I was looking for it!Alabaster
I missed it as well, despite looking for it. Mozilla should consider trying to make it more obvious. Maybe a more traditional command-line style prompt.Mongolic
T
9

Google Chrome has a very nice built-in Javascript console with great debugging and performance analysis functionalities.

Thunderstruck answered 18/6, 2010 at 9:24 Comment(2)
One serious problem of Chrome's javascript console is it doesn't allow multi line editing. The console only evaluates oneliner.Diffidence
@Diffidence you can add new line by press shift+enterAntonetta
B
5

Just to provide another option, check out the shell bookmarklet here. I've been using it for years to run JavaScript against the currently loaded webpage.

The Firebug console is probably a little more feature-rich so I'm not sure there's any compelling reason to use this instead, but it may be a useful tool in some rare cases.

Beadledom answered 12/6, 2010 at 15:52 Comment(0)
E
4

I've been using FireBug, i don't know if it is exactly what you need but i love debugging JavaScript through it.

Because you can print variables to its own console without having to always doing alert(var); you can just do console.log(var)

Expense answered 16/3, 2009 at 10:54 Comment(0)
G
3

The Safari 4 beta has this ability in the error console (in the "Develop" menu). It's especially cool because when it returns an object or HTML node, it lets you delve into it with a little reveal arrow, showing its members, contents, etc.

Garrick answered 16/3, 2009 at 10:53 Comment(0)
C
3

I use firebug console window for this.

Condon answered 16/3, 2009 at 10:54 Comment(0)
A
3

i use JSFiddle online (http://jsfiddle.net/) or seed in a linux terminal (http://live.gnome.org/Seed)

Andre answered 20/7, 2011 at 14:47 Comment(0)
O
3

If you're on a Mac, OSX includes jsc. Nothing new to install, just set up a link:

ln -s /System/Library/Frameworks/JavaScriptCore.framework/Versions/Current/Resources/jsc /usr/local/bin/jsc

Now you can start jsc from a terminal. Type quit() or CTRLC to get out.

Orgasm answered 30/7, 2014 at 22:0 Comment(0)
V
2

A guide to using Firebug's command-line API is here: Link.

Venosity answered 16/3, 2009 at 10:54 Comment(0)
M
2

repl.it supports REPL for number of languages, including JavaScript or you can try Codeacademy Labs it also has JavaScript REPL

Mendie answered 28/6, 2014 at 14:4 Comment(0)
Z
2

LightTable lets you type in code and run it, and shows you the result inline.

Like this:

enter image description here

Zohar answered 15/1, 2015 at 8:49 Comment(0)
L
2

Mancy is an open sourced, cross platform JavaScript REPL application. Its based on electron and react frameworks.

Some neat features:

  • Syntax Highlighting
  • Dark and light themes
  • Import/Export command history
  • Separate console window for async stdout/stderr logs
  • Notification for async console logs
  • console output filter support
  • Traversable output with fold/unfold options
  • Support for adding directory to node path
  • Expand/Collapse/reload command options
  • History traversal support
  • Multiple window
  • Multiline prompt support with shift + enter
  • Auto suggestion
  • Tab completion
  • Code format support
  • Support to toggle REPL mode
  • Preferences for theme and REPL mode

enter image description here

Liquidator answered 14/10, 2015 at 22:16 Comment(0)
P
1

For Chrome You can use jsshell - nice console:

https://chrome.google.com/extensions/detail/kmgmkbicahmbceidoidjbkbpkfogaldh

http://hugoware.net/projects/jsshell

Pithos answered 7/1, 2011 at 17:28 Comment(0)
B
1

I usually use Chrome's built in console. Even recent versions of IE have a decent dev tools window.

JRunscript is super cool (and I'm embarrassed I didn't know about it), but the issues I usually run into are due to variations in javascript implementation or DOM, not the language itself.

Blackguardly answered 11/2, 2011 at 18:50 Comment(0)
A
1

Use osascript on OS X

$ osascript -l JavaScript -i
Andorra answered 18/12, 2015 at 14:42 Comment(0)
S
0

Not exactly REPL but another options for playing around with different libraries in javascript is Google's API playground:

https://code.google.com/apis/ajax/playground/

Spectacle answered 22/2, 2012 at 0:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.