Skip to content

Instantly share code, notes, and snippets.

@jbgo
Created June 17, 2011 15:05
Show Gist options
  • Save jbgo/1031600 to your computer and use it in GitHub Desktop.
Save jbgo/1031600 to your computer and use it in GitHub Desktop.
When using semicolons in JavaScript matters

This fails in Firefox, Chrome, and maybe others.

Copy-and-paste all three lines (at the same time) into a debug console to try it for yourself.

function foo() { /* code goes here */ }
foo() // There is no semi-colon here. Add one to fix there error.
(function() { /* anonymouse function */ })() // bork!

Bork! TypeError: undefined is not a function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment