core
core

Reputation: 33059

Debugging JavaScript REPL-style?

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?

Upvotes: 53

Views: 19167

Answers (20)

Ch0k0l8
Ch0k0l8

Reputation: 837

Use osascript on OS X

$ osascript -l JavaScript -i

Upvotes: 1

Prince John Wesley
Prince John Wesley

Reputation: 63688

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

Upvotes: 2

Rob Grant
Rob Grant

Reputation: 7348

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

Like this:

enter image description here

Upvotes: 2

rymo
rymo

Reputation: 3464

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.

Upvotes: 3

Vlad Bezden
Vlad Bezden

Reputation: 89527

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

Upvotes: 2

Mark Lindell
Mark Lindell

Reputation: 852

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/

Upvotes: 0

Ivan -Oats- Storck
Ivan -Oats- Storck

Reputation: 4326

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

Upvotes: 29

mwx
mwx

Reputation: 604

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

Upvotes: 3

Brent Rockwood
Brent Rockwood

Reputation: 765

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.

Upvotes: 1

mtgred
mtgred

Reputation: 1449

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

Upvotes: 9

devewm
devewm

Reputation: 71

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.

Upvotes: 5

Özgür
Özgür

Reputation: 8247

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.

Upvotes: 9

Sergi Mansilla
Sergi Mansilla

Reputation: 12793

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.

Upvotes: 10

Hank Gay
Hank Gay

Reputation: 71939

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

Upvotes: 23

alxp
alxp

Reputation: 6311

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

Upvotes: 2

Eugene Morozov
Eugene Morozov

Reputation: 15806

I use firebug console window for this.

Upvotes: 3

Ólafur Waage
Ólafur Waage

Reputation: 69981

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)

Upvotes: 4

Jesse Rusak
Jesse Rusak

Reputation: 57168

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.

Upvotes: 3

Related Questions