Wouldn't it be wonderful if you could catch errors before running your code? Lint Checkers allow you to do just that, detect potential problems with your code before you actually run it. Node.js has a module called JSHint that we can install to help us check our code before we run it. Let's go to the command line and install it now. Types in npm install -g and then jshint. Since this is a global module you'll probably need to use sudo to install it.
First, we're going to run clean.js through JSHint, type in jshint and then clean.js. JSHint checked the file and didn't find any problems so it returned us back to the Command prompt. Now let's run messy.js through JSHint. You'll notice that JSHint found five errors with our file. Let's clean this up. First, let's declare this as a variable rather than using the strings as a statement.
And now let's concatenate this properly. If we save the file and go back to the command line and run JSHint again, JSHint doesn't find any problems with messy.js. While Command Line tools like JSHint are helpful, it's much more helpful to have something like this integrated with your IDE or Text Editor. If you use TextMate as your Text Editor, there's a tool that you can use to run JSHint every time you save your file.
- Using the Socket.IO Node package to achieve "live" effects like Facebook notifications
- Scraping web sites using jQuery without a browser
Skill Level Beginner
XHTML and HTML Essential Trainingwith Bill Weinman4h 44m Beginner
1. Installing Node
2. Getting Started
Running a Node script2m 6s
4. Command Line Scripts
5. Creating Web Servers
7. WebSocket Programming
8. Connecting Beyond Node
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.