Issue #19 (Implied eval() and Learning Tools)
Most of us probably know that using eval() is regarded as bad practice. If you use a linting tool like JSLint or JSHint, you'll be able to ensure your code doesn't use eval() unnecessarily. In addition, these tools will also warn you of syntax that uses implied eval(). Here are three such examples:
1. The function constructor
You'll get a warning in many tools and linters about this syntax, which looks like this:
var myFunc = new Function("x", "y", "return x + y");
myFunc(3,4); // 7
To remedy this, you should use a function expression or function declaration.
2. Passing a string literal to a setTimeout() or setInterval() call
This is another form of eval(). Here's an example:
setTimeout("alert('Hello World!');", 3000);
The correct way to do this, to avoid eval-like behavior, is to pass a function instead:
3. Using document.write()
You've most certainly seen this or used it at some point:
When using document.write and linting your code you'll get a warning such as "document.write can be a form of eval", or something similar.
In almost all instances, document.write() is unnecessary and there are perfectly valid alternatives even though they may not do exactly what it does.
For more on the stuff mentioned above, here are some links:
Now on to this week's learning tools!
"Five functions to fill. One ticking clock. How fast can you code?"
Lea Verou used this tool a while back in one of her talks. Write a regular expression, then write a matching string, and the tool will highlight the matched portion and even tell you when there is no match.
"Build software to solve challenges. Compete in online competitions or in-person hackathons for fun and profit."
Hello World Quiz
Guess which programming language by looking at "Hello World!" snippets.
A free course on Code School, it's "a combination of videos, interactive console challenges, and writing code in the browser."
"The game is pretty simple, look at some code & decide if it would trigger an HTTP request in the latest stable release of particular browsers."
A CSS selectors quiz for the more challenging selectors that we may not be as familiar with.
"In each lesson, you'll be given an introduction to a single Markdown concept. Then, you'll be asked to complete several exercises with that new knowledge."
"Codersumo is a community of ninjas, wrestlers, airbenders, samurai and sumo coders. We get better at coding by solving problems."
High Performance Browser Networking
By Ilya Grigorik. Viewable for free online. "Provides what every web developer should know about the network, from fundamental limitations that affect performance to major innovations for building even more powerful browser applications"
List of Free Programming Books
Originally a StackOverflow post, this is now a well-populated GitHub repo.
By Reginald Braithwaite. "A strong cup of functions, objects, combinators, and decorators." Free to read online or you can purchase a proper E-Book.
Design Patterns: Elements of Reusable Object-Oriented Software
This is an old book (1994). It caught my eye because it seems to be a highly recommended book for all programmers. It has well over 300 reviews on Amazon averaging 4.5 stars, which is very impressive.
Web Audio API
By Boris Smus. A short book to get you quickly up to speed with HTML5 audio. Available free online with code examples and demos or for purchase.
By E. Hoigaard. "Discover the beauty of functional programming in CoffeeScript." Free online, and includes an 'Interactive HTML5 edition'.
Podcasts and Newsletters
Web Design Weekly
Curated by Jake Bresnehan, one of the well-known "weeklies". Always good links and there's usually (always?) a section on new tools.
A podcast by John Macpherson covering various front-end development/design topics, and also includes interviews with well-known web personalities.
A WordPress-focused podcast by by Brad Touesnard and Pippin Williamson.
"An in-depth discussion on the latest tooling, workflow and best practices for front-end developers." Hasn't been updated recently, but the archives might be worth a listen.
Hosted by Garann Means and Divya Manian, with occasional guests. Lots of good stuff on front-end engineering and related topics.
One of the many Cooper Press weeklies, I believe this is one of their newest, with a focus on Node.js news and articles.
Suggest Your Tool via Twitter
Made something? Send links via Twitter @WebToolsWeekly (details here). No tutorials or articles, please.
3 CSS E-Books for $7!
To help Web Tools Weekly stay ad free, you can offer support:
Suggestions, corrections, improvements? Feel free to reply to this email.
Before I Go...
Keeping with the theme of learning tools, typing.io helps you practice your typing speed but in the context of programming. Choose from lots of different languages and there's even a pay option with lots of extra features.
Thanks to all for subscribing and reading!