Wrapping methods up in a JavaScript object -
i have need this:
<script src="apiwrapper.js"></script> <script> apiwrapper.init('api_key'); apiwrapper.dosomethingelse(); </script>
essentially, have singleton style object in page can add methods , properties , have available anywhere within page.
what's best way this?
you use approach (which gives way of having private properties/functions):
var apiwrapper = apiwrapper || (function () { /* private functions here */ var privatefunction = function () { } /* public functions here */ return { init: function (opts) {}, dosomethingelse: function () {} }; })();
Comments
Post a Comment