Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript jQuery Basics (2014) Creating a Simple Lightbox Creating and Appending Detached DOM elements

Paul Barron
Paul Barron
6,595 Points

The Almighty " ; "

I'm working learning javaScript and jQuery. The syntax is killing me. when we put write a function as an argument do we separate all expressions and variables? So for instance:

$("imageGallery a").click(function(event){ event.preventDefault(); var href = $(this).attr("href"); console.log("href") $overlay.show(); });

Basically, what I'm asking is, Does the semi-colon separate all working parts of script? Is it safe to assume that whatever is between semi-colons is separate from other semi-colon'ed parts? I'm sorry if I'm not clear in my question. But like I said the syntax is killing me.

1 Answer

A semicolon indicates an end of a line of code. When you indicate a semicolon, that means that the statement is finished. It's akin to putting a period at the end of a sentence.

$('#myID').hide().fadeIn(); <-- the semi colon ends the line.

Paul Barron
Paul Barron
6,595 Points

Certainly helped me better understand it better.