tsiki
tsiki

Reputation: 1799

What's the meaning of .js file of the form "define([...], function(...) {...});"

I have .js files of the following form:

define([
   'jquery',
  'backbone'
], function($, Backbone) {
  // function stuff here
}

What's the purpose of writing the file that way? Is it some convention to define it like that?

Upvotes: 3

Views: 1356

Answers (1)

Interrobang
Interrobang

Reputation: 17434

They're using the CommonJS AMD-style definitions to register modules.

Info: http://www.sitepen.com/blog/2010/11/04/requirejsamd-module-forms/

The first argument is the module dependencies, and the second is the module itself.

Upvotes: 1

Related Questions