I was looking through file upload plugin's javascript code.
There is a piece of code which checks if define is a function and declares a few dependencies i guess
(function (factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
// Register as an anonymous AMD module:
define([
'jquery',
'jquery.ui.widget'
], factory);
} else {
// Browser globals:
factory(window.jQuery);
}
}
The comments just above the code says define is global. But i dont have it in my application built using angularjs.
I searched the codebase for declaration of define. BUt couldn't find any. I googled for AMD and i could see define being used here again.
My question is where is 'define' defined?
define
is a function whose functionality is defined by the Asynchronous Module Definition specification. AMD is just a spec; there's multiple implementations, of which RequireJS is one. You could see how RequireJS implements it if you want, but keep in mind that RequireJS's define
isn't the only define
out there.