Lessons learned @ Grensesnittet Javascript meetup

May 13th, 2011 § 0 comments

Two days ago, I attended the “Skriv bedre javascript” meetup in Trondheim.

7 quick lectures, 10 minutes each. One half broken iPhone as a notepad.

  • parseInt has not one, but two parameters. Pass 10, and you’ll avoid silly problems because the passed string is interpreted as the wrong numeric system.
  • If you use (for something in yourarray), you’ll most likely end up with tons more of entries than expected. Better use HasOwnProperty, or a regular for loop.
  • If you skip on the semi colons, the parser will guess what you were trying to say.
  • If you loop strings, string[i] == ‘A’ is…. unstabile. Use string.charAt(i) == ‘A’
  • If your function takes time to complete, setInterval will get you into trouble, queuing calls to your function. Rewrite to use setTimeout at the end of the function instead.
  • eval is evil
  • Be aware of closures
  • Javascript has packages
  • Douglas Crockford knows javascript better than both you and I. No, really!
  • Javascript has global scope and function scope, but not block scope. Srry.
  • Hoisting has some rules about parsing variable declarations. If you run into weirdness problems, that might be the answer. Declare your variables at the top, please.
  • jsLint checks the quality of your code according to some criterias, but isn’t the one-stop solution.
  • Avoid alert and console.log. Both suck in all or some browsers (I’m looking at you, IE). Use a debugger framework, such as log4js, blackbird or Ben Alman javascript debugger.
  • Easy jquery plugins are…. well…. as easy as …. erhm…. let’s just say they are simple to implement.
  • jquery UI Widget Factory structures a way to create plugins. Part of jquery UI.
  • Cool stuff in the HTML5 js library: a few new calls, web storage, offline application cache api, web workers, web sockets, drag/drop, geo location, canvas and audio manipulation.
  • Same origin policy could have been a problem for js-based twitter clients, except for the entry of json-p.
  • Prezi is nice for presentations.
  • Microtemplates, by a guy named John Reisig.

And, at the top of this, some more details about Canvas and some of the stuff named here, that I just decided to Google when I need it. Two hours well spent.

This post is for the technical oriented among us. For the rest of you, sorry – we’ll get back to the regular broadcasting soon enough!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>