InterviewSolution
| 1. |
Write The Code To Define A Requirejs Module With Its Dependencies? |
|
Answer» The RequireJS is a DEPENDENCY management tool that can be used by the USER to manage script modules. It can be used to load scripts once a PAGE has been loaded. This helps in EVENLY distributing the DOWNLOADS. For example: RequireJS module with dependencies defined: require.def("my/shirt",["my/cart", "my/inventory"], function(cart, inventory) { //return an object to define the "my/shirt" module. return { color: "blue", size: "large" addToCart: function() { inventory.decrement(this); cart.add(this); } } } ); In the above example the my.shirt module is created. This module depends on the my/cart and my/inventory. The RequireJS is a dependency management tool that can be used by the user to manage script modules. It can be used to load scripts once a page has been loaded. This helps in evenly distributing the downloads. For example: RequireJS module with dependencies defined: In the above example the my.shirt module is created. This module depends on the my/cart and my/inventory. |
|