Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between these 2 JavaScript declarations?

Tags:

People also ask

What are declarations in JavaScript?

Creating a variable in JavaScript is called "declaring" a variable.

Is there a difference between and in JavaScript?

No difference in JavaScript. The only requisite is that the last quotation mark matches the first quotation mark. In other languages they may have different applications but in JavaScript they are exactly the same.

What is the difference between statement and expression JavaScript?

for statement , while statement , if statement , they are all actions, in another word tasks, or behaviors. But for expression , we are talking about values, valuables, objects, or some procedures that can produce a value, like function. So Javascript also has function expression . Because function is a value .


For one of them the "()" is inside, for the other one it is outside. Here they are:

var a = (function() {
    return {
        bla: function() {
            console.log('a');
        }
    };
} () );

var b = (function() {
    return {
        bla: function() {
            console.log('b');
        }
    };
}) ();

a.bla();
b.bla();