+ All Categories
Home > Technology > "JavaScript: The Good Parts" Summary

"JavaScript: The Good Parts" Summary

Date post: 29-Nov-2014
Category:
Upload: jonathan-julian
View: 5,308 times
Download: 1 times
Share this document with a friend
Description:
A summary of Douglas Crockford's amazing book "JavaScript: The Good Parts". First presented at the Baltimore/DC JavaScript Users Group on 7/7/2009. http://www.meetup.com/baltimore-dc-javascript-users/calendar/10560330/
27
JavaScript: The Good Parts @jonathanjulian
Transcript
Page 1: "JavaScript: The Good Parts" Summary

JavaScript: The Good Parts@jonathanjulian

Page 2: "JavaScript: The Good Parts" Summary
Page 3: "JavaScript: The Good Parts" Summary
Page 4: "JavaScript: The Good Parts" Summary

crockford.com

Page 5: "JavaScript: The Good Parts" Summary

First, the Bad Parts

Page 6: "JavaScript: The Good Parts" Summary

globals. optional ;truthy/falsy. scope.

Page 7: "JavaScript: The Good Parts" Summary

Then, the Good Parts!

Page 8: "JavaScript: The Good Parts" Summary

functions as objects. loose typing.dynamic objects. literals.

Page 9: "JavaScript: The Good Parts" Summary

The Bad Parts

Page 10: "JavaScript: The Good Parts" Summary

globals

• x = 1;

• var y = 1;

• x is in the global namespace

• YourAppName.x = 1;

Page 11: "JavaScript: The Good Parts" Summary

line termination

• semi-colons are INSERTED by the parser

• optional semi-colons are not a “language feature”

• you are not warned

Page 12: "JavaScript: The Good Parts" Summary

truthy / falsy

Page 13: "JavaScript: The Good Parts" Summary

==

Page 14: "JavaScript: The Good Parts" Summary

===

All of these are false

Page 15: "JavaScript: The Good Parts" Summary

take advantage

• if (x)

• if (myobject.propery)

• if (myobject.property == null) // no, No, NO!

• test for exactly what you want to test for

• ...or not

• KNOW THE FALSY VALUESundefined, null, false, 0, ‘’, NaN

Page 16: "JavaScript: The Good Parts" Summary

no block scope

• functions create scope

• blocks do not

Page 17: "JavaScript: The Good Parts" Summary

The Good Parts!

Page 18: "JavaScript: The Good Parts" Summary

functions are objects

• can be passed, returned

• have scope

• have closure

Page 19: "JavaScript: The Good Parts" Summary

loose typing

• no compiler

• no type heirarchies

Page 20: "JavaScript: The Good Parts" Summary

objects are dynamic

• members can be added to any object, any time

• helpful to attach attributes

Page 21: "JavaScript: The Good Parts" Summary

object literals

• aka JSON

• { count: 2, prefix: ‘pre_’ }

• pass options to functions

• JSON as communication

• JSON as persistence

• etc

Page 22: "JavaScript: The Good Parts" Summary

Know the bad parts are there...and avoid them

Page 23: "JavaScript: The Good Parts" Summary

Learn and love the good parts!

Page 24: "JavaScript: The Good Parts" Summary

tools

• FireBug

• JSLint

• spidermonkey / rhino / v8

Page 25: "JavaScript: The Good Parts" Summary

takeaway

• think about vars and scope

• never use ==

• if (myobject) {

• jslint.com

Page 26: "JavaScript: The Good Parts" Summary

JavaScript is a beautiful language


Recommended