python ruby-programming-language Smalltalk Vue.js Knockoutjs TypeScript JavaScript, OOPs JavaScript Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 4 Angular 2 AngularJs 1.x NodeJs Perl Programming R Programming RequireJs Rust Programming Backbonejs closure programming language go-programming-language kotlin-programming-language
Asynchronous Module Definition (AMD) Modules

What Are AMD Modules In RequireJS?

What Is AMD module?

The AMD is stands for Asynchronous Module Definition and is used for defining modules and their dependencies with asynchronously manner.


Defining Modules -The Module is defined using define () method and it used for loading the module i.e.
define({
  country:"India",
  state: "UP",
  city: "Noida",
  userDetail: function () {
           return "User Detail";
    }
});

Defining Functions - A module can also use a function without dependencies i.e.
define(function () {
    return {
        country:"India",
        state: "UP",
        city: "Noida"
    }
});

Defining Functions with Dependencies - The Dependencies module looks like.
define(["../comp""../user"],
  function(compuser) {
      return {
          country:"India",
          state: "UP",
          city: "Noida",     
          addUser: function() {
            comp.decrement(this);
            user.add(this);
          }     
      }
});

Defining a Module as a Function - Its looks like.
define(["../comp""../user"],
    function(compuser) {
      return function(userName){
          return userName != null ? userName :'NA'
      }
});

Defining a Module with a Name - Its looks like.
define("Users", ["../comp""../user"],
  function(compuser) {
    return {
        country:"India",
        state: "UP",
        city: "Noida",     
        addUser: function() {
          console.log(this);
        }     
    }
});


I hope you are enjoying with this post! Please share with you friends!! Thank you!!!
ANIL SINGH

Hi there! Welcome to my blog. My name is Anil Singh. I'm a author of this blog. For more detail about me, kindly refer to this link..
My Blogs - http://code-sample.com and http://code-sample.xyz
My Books - Interview Questions and Answers Books- Get Your Book in 15+ Digital Stores Worldwide..

You Might Also Like
www.code-sample.com/. Powered by Blogger.
ASK Questions