JSLent: give it up for JavaScript
Upcoming SlideShare
Loading in...5
×
 

JSLent: give it up for JavaScript

on

  • 1,160 views

Simple ways to improve your JavaScript code.

Simple ways to improve your JavaScript code.

Statistics

Views

Total Views
1,160
Views on SlideShare
960
Embed Views
200

Actions

Likes
0
Downloads
2
Comments
0

6 Embeds 200

http://openupstate.org 175
http://www.openupstate.org 9
http://coderwall.com 8
http://openupstate.com 5
http://www.linkedin.com 2
http://www.openupstate.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

CC Attribution License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

JSLent: give it up for JavaScript JSLent: give it up for JavaScript Presentation Transcript

  • JSLent give it up for JavaScriptTuesday, March 22, 2011
  • Whither JS? • In the browsers (obviously) • On the server • node.js (V8) • narwhal.js (Rhino & friends) • In your database • if it’s CouchDBTuesday, March 22, 2011
  • eschew evalTuesday, March 22, 2011
  • how prototypicalTuesday, March 22, 2011
  • function Person(){} Person.prototype.getName = function(){ return this.name; }; function Me(){ this.name = "John Resig"; } Me.prototype = new Person(); var me = new Me(); me.getName(); // "John Resig" http://ejohn.org/apps/learn/#78Tuesday, March 22, 2011
  • getting it right buy the bookTuesday, March 22, 2011
  • Meet Douglas Crockford • author of JavaScript: the Good Parts • minified JS education • works at Yahoo! • checkout YUI Theatre • also javascript.crockford.comTuesday, March 22, 2011
  • He begat JSLint • cleans up your JS • will hurt your feelingsTuesday, March 22, 2011
  • (function() { four = eval(2+2); var eight = multiply(four, 2); function multiply(n,y) { return n*y } if (typeof eight == string) { console.log(fale); } });Tuesday, March 22, 2011
  • Problem at line 2 character 8: eval is evil. (function() { multiply was used before it was defined. four = eval(2+2); var eight = multiply(four, 2); function multiply(n,y) { return n*y Expected ; and instead saw }. } if (typeof eight == string) { console.log(fale); Expected === and instead saw ==. } }); Do not wrap function literals in parens unless they are Expected an assignment or function ca# and to be immediately invoked. instead saw an expression.Tuesday, March 22, 2011
  • see?Tuesday, March 22, 2011
  • JSLint: finds...stuff • Undefined Vars & Functions • Globals/Members lists • Semicolon checking • clean blocks • checks for break in switchTuesday, March 22, 2011
  • more stuff • singe var at the top • no more with • better comparisons • == vs === • eval is Evil (but you knew that already)Tuesday, March 22, 2011
  • Awful Parts • Global Variables • Scope (confusing/misleading variable scope) • Semicolon Insertion • Reserved WordsTuesday, March 22, 2011
  • Reserved Words • boolean • final • short • break • finally • switch • byte • float • this • case • for • throw • catch • function • true • char • if • try • continue • in • typeof • default • instanceof • var • delete • int • void • do • long • while • double • new • with • else • null • false • returnTuesday, March 22, 2011
  • Resources • jslint.com • jshint.com • ejohn.org/apps/learn/Tuesday, March 22, 2011