Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

MOOC: Require vs Define in RequireJS

SanjeevChauhanAug 22 2016 — edited Aug 22 2016

This question is more on requirejs but I would like to hear from experts.

I see we have called require and define method of require.js.

I see signatures as

require(array-of-strings,callback-function-returning-an-object)

define(callback-function-returning-an-object)

It seems like require is like asking "load following libraries and then call the callback function. Pass module defined by those libraries as input to callback function."

define is like "Define a module with lots of properties"

Is my understanding OK (I know its just a surface)? It will be good if you can throw some more light.

What is the significance of below signature

define(array-of-strings,callback-function-returning-an-object) --> Is it doing same stuff as done by require method? Loading libraries and then calling callback by their defined modules.

Thanks

Sanjeev.

Comments
Post Details
Added on Aug 22 2016
1 comment
613 views