I am new to javascript. Can somebody explain me what this below code does. It not seems like regular javascript. Is this uses any framework like node.js or underscore.js?.
What do 'exports and other functions do here. Just give me a brief idea about this library file.
(function (exports, global) {
"use strict";
var _ = {};
exports.internal = _;
exports.debugLogEnabled = true;
_.debug = function (x) {
if (exports.debugLogEnabled) {
console.log(x);
}
};
_.removeAllElements = function (array) {
array.length = 0;
};
_.addElements = function (array, elements) {
elements.forEach(function (element) {
array.push(element);
});
};
_.contains = function (array, element) {
return array.indexOf(element) >= 0;
};
_.isUndefined = function (x) {
return typeof(x) === 'undefined';
};
_.setDefault = function (obj, key, defaultValue) {
if (_.isUndefined(obj[key])) {
obj[key] = defaultValue;
}
};
_.forKeyValue = function (obj, f) {
var key;
for (key in obj) {
if (obj.hasOwnProperty(key)) {
f(key, obj[key]);
}
}
};
_.merge = function (obj, defaults) {
_.forKeyValue(defaults, function (key, value) {
_.setDefault(obj, key, value);
});
};
};
})(typeof exports === 'undefined' ? this.sec = {} : exports, this);