Skip to main content

Posts

Showing posts with the label RequireJs Interview Questions and Answers

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...

31 Best RequireJs Interview Questions and Answers

What is RequireJS? ü   RequireJS is a JavaScript library and AMD   compatible asynchronous module loader. ü   RequireJS is used to loads the JavaScript files and resolve their dependencies and its supported to the latest versions of popular browsers. ü   RequireJS helps to improve the performance and code of quality. ü   RequireJS was developed by David Mark. Its open source and it was released in 2009. ü   RequireJS is used by node.js to fetch and load module. ü   RequireJS contains a small set of plugins which allow us to loading the various types of resources like text, Dom Ready, i18n, CSS and loading. RequireJS includes three main API functions - ü   Define () - This function is used to define a module. Each module is defined a unique module ID. This module Id is used by RequireJS at the runtime. ü   Require () - This function is used to load dependencies and It is a global function. ü   Config () - This ...