3 ms·
Like dangrossman said, use console.log. Check out these videos from Paul Irish on using console effectively: http://www.youtube.com/watch?v=4mf_yNLlgic http:/
by malandrew 15y ago
Like dangrossman said, use console.log.
Check out these videos from Paul Irish on using console effectively:
http://www.youtube.com/watch?v=4mf_yNLlgic http://www.youtube.com/watch?v=4mf_yNLlgic
http://www.youtube.com/watch?v=nOEw9iiopwI http://www.youtube.com/watch?v=nOEw9iiopwI
Since you are an emacs user, you may want to try mooz's community fork of Yegge's js2-mode
https://github.com/mooz/js2-mode https://github.com/mooz/js2-mode
Haven't tried it myself, but you may also want to look at Moz Repl in emacs. http://www.emacswiki.org/emacs/MozRepl http://www.emacswiki.org/emacs/MozRepl
Finally, check out Christian Johansen's and Magnar Sveens .emacs.d for some ideas on how to set up your emacs for javascript.
https://github.com/magnars/.emacs.d https://github.com/magnars/.emacs.d
https://github.com/cjohansen/.emacs.d https://github.com/cjohansen/.emacs.d
For TDD, you 3 main options worth checking out are:
Buster.js looks really promising and does both server-side and client-side testing.
If you don't like buster.js for whatever reason, Mocha is a popular node.js server-side testing option and Jasmine is a popular client-side testing option.
- benjaminwootton 15y agoThis is great - thanks! Are there any other good screencasts similar to the Railscasts?
- malandrew 15y agoThe only other video that sticks out in mine head is this Google Tech Talk by Nicholas Zakas about javascript performance. http://www.youtube.com/watch?v=mHtdZgou0qU http://www.youtube.com/watch?v=mHtdZgou0qU Besides videos, check out Javascript Garden: http://bonsaiden.github.com/JavaScript-Garden/ http://bonsaiden.github.com/JavaScript-Garden/ Javascript Weblog: http://javascriptweblog.wordpress.com/ http://javascriptweblog.wordpress.com/ Here are some links over on Quora: http://www.quora.com/What-are-the-best-resources-for-learning-JavaScript http://www.quora.com/What-are-the-best-resources-for-learnin... The three books worth getting for someone who is already a programmer are: Crockford's "Javascript: The Good Parts", Stoyan Stefanov's "Javascript Patterns", and Resigs's "Secrets of the Javascript Ninja" IMHO, there are few videos worthwhile.
- pault 15y agoHasn't SOTJN been in early access mode for like 3 years? I bought a copy way back when it was first released but I've given up on it ever being finished.
- jarek-foksa 15y agoI would add one very useful hint which was not mentioned in Paul's videos: place the word "debugger" (without quotes) anywhere in your script to set a breakpoint.
- adrianparsons 15y agoI'm always surprised more people don't know this. I haven't seen it any books and only occasionally in tutorials. I use it dozens of times a day -- it's critical for writing and understanding JS.
- bcrescimanno 15y agoBreakpoints, yes. But many folks (myself included) set the breakpoints in the debugger itself--you don't have to put that line into your code to set a breakpoint. Since some folks write JS that has to go through a "build" process, it's easier to set a breakpoint in the debugger than to go back, modify the code, and "re-build" to get a breakpoint.
- jarek-foksa 15y agoIt would be even easier if you could just fix the build system. If you are worried to modify your code because of the long build process then the build system probably needs rethinking - make sure that only the files that were modified are rebuilt, configure your text editor so that it runs build script on file save.
- bcrescimanno 15y agoIt's not that it's long, it's that it has to be done at all. Even without a build process (or one like ours that takes at most 5-10 seconds) it still takes longer than finding the line of code you're concerned about and setting a breakpoint within the debugger itself. To each there own as to how setting breakpoints works best for them in their workflow--my only reason for commenting was to let people know there were other ways to set breakpoints than adding "debugger" lines all over their code.
- tikhonj 15y agojs2 mode, especially mooz's fork, is really, really awesome! Another minor-mode to consider is js2-refactor[1], which leverages js2 mode to make refactoring JavaScript code easier on Emacs. [1]: https://github.com/magnars/js2-refactor.el https://github.com/magnars/js2-refactor.el I haven't used it myself because I haven't done any JavaScript since finding out about it, but it seems like a brilliant addition to the already superb Emacs JavaScript experience. You can also set up flymake mode with JSHint[2] to get style tips and warnings in your buffer[3]. JSHint is like JSLint but more configurable. [2]: http://www.jshint.com/ http://www.jshint.com/ [3]: https://github.com/daleharvey/jshint-mode https://github.com/daleharvey/jshint-mode