0

I saw sometime people add ; or ! at the beginning of the javascript file, but wonder what benefits you will get.

;(function (_global, _other) {
    "use strict";
    var _global = GLOBAL || {};
    _global.thisModule = _global.thisModule || {};
    var _this = _global.thisModule;

    _this.remove = function (value) {
        if (typeof value !== "string" || !value) {
            return value;
        }

        return value.replace(_other.balabala, '');
    };
}(GLOBAL || {}, GLOBAL.OTHER));
user2650480
  • 429
  • 2
  • 5
  • 17
  • http://stackoverflow.com/questions/7145514/whats-the-purpose-of-starting-semi-colon-at-beginning-of-javascript – AmmarCSE Jul 27 '15 at 21:02
  • http://stackoverflow.com/questions/1873983/what-does-the-leading-semicolon-in-javascript-libraries-do – j08691 Jul 27 '15 at 21:02
  • See relevant answer in a similar question http://stackoverflow.com/a/1873999/3716159 – Peter Šándor Jul 27 '15 at 21:05
  • 1
    http://stackoverflow.com/questions/3755606/what-does-the-exclamation-mark-do-before-the-function – j08691 Jul 27 '15 at 21:05
  • See [JavaScript Bang “!” Functions vs Leading Semi-Colon “;” IIFEs](http://stackoverflow.com/q/24067605/1048572) which lays out the differences – Bergi Jul 27 '15 at 21:14

0 Answers0