Reputation:
I'm trying to build a library that uses strict.
/*jslint */
(function() {
'use strict';
function MyLibrary() {
}
MyLibrary.prototype.add = function () {
}
}());
var usersLibrary = new MyLibrary();
I'm trying to stick with the classical syntax for instantiating classes (using "new"). Unfortunately, I can't call myLibrary because it's scope is within the function.
Upvotes: 0
Views: 83
Reputation: 413826
Explicitly add it to the global context:
(function(global) {
'use strict';
function myLibrary() {
}
myLibrary.prototype.add = function () {
}
global.myLibrary = myLibrary;
}(this));
Upvotes: 2