Skip to main content
added 2 characters in body
Source Link
kornieff
  • 2.6k
  • 22
  • 29

Missed a ; after declaring b. The following code is equivalent to what you have.

var b = function() {
   console.log ('outer world');
}(function() {})();

Without the ; b becomes self-executing and takes an empty function as a parameter. After that it self-executes again; however, because b does not return a function, you get an exception.

I suggest not to skip ; until you become js ninja :). Keep b inside to avoid global scope pollution.

(function () {
    "use strict";

    var b = function () {
        console.log("hi");
    };
    // other code
}());

Semicolon auto-insertion discussion

In case you do not want semicolons, add an operator before self-running function

var b = function () { console.log('outer world') }
;(function() { /* ... */ }())

ES6 Update:

(() => {
  letconst b = () => console.log('hi')
  // ...
})()

Missed a ; after declaring b. The following code is equivalent to what you have.

var b = function() {
   console.log ('outer world');
}(function() {})();

Without the ; b becomes self-executing and takes an empty function as a parameter. After that it self-executes again; however, because b does not return a function, you get an exception.

I suggest not to skip ; until you become js ninja :). Keep b inside to avoid global scope pollution.

(function () {
    "use strict";

    var b = function () {
        console.log("hi");
    };
    // other code
}());

Semicolon auto-insertion discussion

In case you do not want semicolons, add an operator before self-running function

var b = function () { console.log('outer world') }
;(function() { /* ... */ }())

ES6 Update:

(() => {
  let b = () => console.log('hi')
  // ...
})()

Missed a ; after declaring b. The following code is equivalent to what you have.

var b = function() {
   console.log ('outer world');
}(function() {})();

Without the ; b becomes self-executing and takes an empty function as a parameter. After that it self-executes again; however, because b does not return a function, you get an exception.

I suggest not to skip ; until you become js ninja :). Keep b inside to avoid global scope pollution.

(function () {
    "use strict";

    var b = function () {
        console.log("hi");
    };
    // other code
}());

Semicolon auto-insertion discussion

In case you do not want semicolons, add an operator before self-running function

var b = function () { console.log('outer world') }
;(function() { /* ... */ }())

ES6 Update:

(() => {
  const b = () => console.log('hi')
  // ...
})()
added 91 characters in body
Source Link
kornieff
  • 2.6k
  • 22
  • 29

Missed a ; after declaring b. The following code is equivalent to what you have.

var b = function() {
   console.log ('outer world');
}(function() {})();

Without the ; b becomes self-executing and takes an empty function as a parameter. After that it self-executes again; however, because b does not return a function, you get an exception.

I suggest not to skip ; until you become js ninja :). Keep b inside to avoid global scope pollution.

(function () {
    "use strict";

    var b = function () {
        console.log("hi");
    };
    // other code
}());

Semicolon auto-insertion discussion

In case you do not want semicolons, add an operator before self-running function

var b = function () { console.log('outer world') }
;(function() { /* ... */ }())

ES6 Update:

(() => {
  let b = () => console.log('hi')
  // ...
})()

Missed a ; after declaring b. The following code is equivalent to what you have.

var b = function() {
   console.log ('outer world');
}(function() {})();

Without the ; b becomes self-executing and takes an empty function as a parameter. After that it self-executes again; however, because b does not return a function, you get an exception.

I suggest not to skip ; until you become js ninja :). Keep b inside to avoid global scope pollution.

(function () {
    "use strict";

    var b = function () {
        console.log("hi");
    };
    // other code
}());

Semicolon auto-insertion discussion

In case you do not want semicolons, add an operator before self-running function

var b = function () { console.log('outer world') }
;(function() { /* ... */ }())

Missed a ; after declaring b. The following code is equivalent to what you have.

var b = function() {
   console.log ('outer world');
}(function() {})();

Without the ; b becomes self-executing and takes an empty function as a parameter. After that it self-executes again; however, because b does not return a function, you get an exception.

I suggest not to skip ; until you become js ninja :). Keep b inside to avoid global scope pollution.

(function () {
    "use strict";

    var b = function () {
        console.log("hi");
    };
    // other code
}());

Semicolon auto-insertion discussion

In case you do not want semicolons, add an operator before self-running function

var b = function () { console.log('outer world') }
;(function() { /* ... */ }())

ES6 Update:

(() => {
  let b = () => console.log('hi')
  // ...
})()
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

Missed a ; after declaring b. The following code is equivalent to what you have.

var b = function() {
   console.log ('outer world');
}(function() {})();

Without the ; b becomes self-executing and takes an empty function as a parameter. After that it self-executes again; however, because b does not return a function, you get an exception.

I suggest not to skip ; until you become js ninja :). Keep b inside to avoid global scope pollution.

(function () {
    "use strict";

    var b = function () {
        console.log("hi");
    };
    // other code
}());

Semicolon auto-insertion discussionSemicolon auto-insertion discussion

In case you do not want semicolons, add an operator before self-running function

var b = function () { console.log('outer world') }
;(function() { /* ... */ }())

Missed a ; after declaring b. The following code is equivalent to what you have.

var b = function() {
   console.log ('outer world');
}(function() {})();

Without the ; b becomes self-executing and takes an empty function as a parameter. After that it self-executes again; however, because b does not return a function, you get an exception.

I suggest not to skip ; until you become js ninja :). Keep b inside to avoid global scope pollution.

(function () {
    "use strict";

    var b = function () {
        console.log("hi");
    };
    // other code
}());

Semicolon auto-insertion discussion

In case you do not want semicolons, add an operator before self-running function

var b = function () { console.log('outer world') }
;(function() { /* ... */ }())

Missed a ; after declaring b. The following code is equivalent to what you have.

var b = function() {
   console.log ('outer world');
}(function() {})();

Without the ; b becomes self-executing and takes an empty function as a parameter. After that it self-executes again; however, because b does not return a function, you get an exception.

I suggest not to skip ; until you become js ninja :). Keep b inside to avoid global scope pollution.

(function () {
    "use strict";

    var b = function () {
        console.log("hi");
    };
    // other code
}());

Semicolon auto-insertion discussion

In case you do not want semicolons, add an operator before self-running function

var b = function () { console.log('outer world') }
;(function() { /* ... */ }())
added 2 characters in body
Source Link
kornieff
  • 2.6k
  • 22
  • 29
Loading
added 175 characters in body
Source Link
kornieff
  • 2.6k
  • 22
  • 29
Loading
added 170 characters in body
Source Link
kornieff
  • 2.6k
  • 22
  • 29
Loading
Source Link
kornieff
  • 2.6k
  • 22
  • 29
Loading
Post Undeleted by kornieff
Post Deleted by kornieff
Source Link
kornieff
  • 2.6k
  • 22
  • 29
Loading