Explain the following JavaScript statement? [duplicate]

This code is equivalent to:

function Ninja() {
    // nothing here
}

var ninja = new Ninja();

Though in the code you listed, the function/object Ninja is not global scope.

The code (function() {...})(); basically says “take whatever function is contained inside here and execute it immediately”. So it’s creating an anonymous function and calling it right afterwards.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)