Last Updated: February 25, 2016
·
600
· ashokraj

In Javascript/Jquery use ';' more to avoid errors/confusions

JavaScript is a very flexible and mysterious language.
Sometimes when we use lots of inner functions & library calls,
such as

$('#div').click(function(){  //code
});
(function (){ //code
 });

we can just put a ";" before like,

;(function (){ //code
 });

just to avoid errors & confusion as the code gets bigger, we won't have any idea where we are missing ";".

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside