Skip to main content

Posts

Showing posts with the label RequireJS Require vs Define

When Should I use Require() and when to use Define()? [Require vs Define]

The define () method looks like - ü    The define () method is used for facilitating module definition ü    The define () method accepts two optional parameters module ID and array of required modules [dependencies] ü    The define() method MUST return the implementation for your module i.e. define (    module_id   /*optional*/ ,   [ dependencies ]  /*optional*/ ,    definition   function   /*function for instantiating the module or object*/ ); And define ([ 'moduleA' ,  'moduleB' ],  function  ( moduleA ,  moduleB ) {    //define the module value by returning a value    return   function  () {}; }); The require () method looks like - ü    The require () method is used for handling dependency loading ü    The require () function doesn't have to return the implementation of a new module. require ([ 'j...