|
|
Issue #19 (Implied eval() and Learning Tools)11/28/13
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:
setTimeout(function() {
alert("Hello World!");
}, 3000);
|
3. Using document.write()
You've most certainly seen this or used it at some point:
document.write("Example text.");
|
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!
Interactive Tools
Dash
"Teaches HTML, CSS, and Javascript through fun projects you can do in your browser."
Object Playground
Part of the "Let's Code: Test-driven JavaScript" series, this lesson includes an on-page code visualization tool to help you grasp object-oriented concepts in JavaScript.
You Can't JavaScript Under Pressure
"Five functions to fill. One ticking clock. How fast can you code?"
RegExp Playground
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.
ChallengePost
"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.
Programmr
Solve coding exercises, make awesome projects and win cool contests. Includes Ruby, JavaScript, HTML/CSS, PHP and lots more.
Try jQuery
A free course on Code School, it's "a combination of videos, interactive console challenges, and writing code in the browser."
Request Quest
"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."
CSS Quiz
A CSS selectors quiz for the more challenging selectors that we may not be as familiar with.
Markdown Tutorial
"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
"Codersumo is a community of ninjas, wrestlers, airbenders, samurai and sumo coders. We get better at coding by solving problems."
Books
Human JavaScript
E-Book by Henrik Joreteg. "Practical patterns for simple but powerful JavaScript apps." Includes a lifetime subscription to book updates with purchase.
jQuery Trickshots
By Martin Angelov. In his words: "100 advanced jQuery techniques that I have developed over the years as a JavaScript programmer and author for Tutorialzine, presented as easy to understand tips."
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.
JSbooks
Yet another list of free books, this time focused on JavaScript.
JavaScript Allongé
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.
Smooth CoffeeScript
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.
Web Payload
A podcast by John Macpherson covering various front-end development/design topics, and also includes interviews with well-known web personalities.
Apply Filters
A WordPress-focused podcast by by Brad Touesnard and Pippin Williamson.
Upfront Podcast
"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.
Fripfrap
Hosted by Garann Means and Divya Manian, with occasional guests. Lots of good stuff on front-end engineering and related topics.
Node Weekly
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:
Criticism? Corrections?
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!
Keep tooling,
Louis
webtoolsweekly.com
@WebToolsWeekly
|
|
|
|
|
|