Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8390471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:59:45+00:00 2026-06-09T18:59:45+00:00

I am intermediate level javascript developer trying to understand how great javascript developer write

  • 0

I am intermediate level javascript developer trying to understand how great javascript developer write their code and i decide to start looking into Backbone library as starting point.

here is some code snippet for initial setup in backbone please help me to make sense out of it.

code1 –

(function(){
   var root = this;
}).call(this);

is there any specific reason to use call method over simply using (), or it is just a coding preference, if i have to write the same code i would do something like this.

(function(root){

})(this);

code2 –

  var Backbone;
  if (typeof exports !== 'undefined') {
    Backbone = exports;
  } else {
    Backbone = root.Backbone = {};
  }

now there is no definition of export in the global scope nor it is defined anywhere in local scope then what is if block is doing here if i was writing the same code i would write

  var Backbone = root.Backbone = {};

code 3

var _ = root._;
if (!_ && (typeof require !== 'undefined')) _ = require('underscore')._;

again I can’t find definition of require anywhere in local or global scope

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T18:59:47+00:00Added an answer on June 9, 2026 at 6:59 pm

    Code Block 1

    This is down to developer preference, you could write that code either way and, indeed, many libraries do prefer your suggested style.

    Code Block 2

    This block is a take on the AMD Boiler Plate. AMD libraries provide the hooks required to split your JavaScript code into modules. In the code blocks case, the exports object is a global used by the CommonJS Module Standard. If the exports global is not present then Backbone is added to the root object directly.

    An interesting side note on this is the fact that Backbone does not support exporting to the popular RequireJS AMD library.

    Code Block 3

    require is another global introduced by AMD libraries, see above.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just decide to learn backbone.js. I am a between junior and intermediate level
Good morning - I'm an intermediate-level developer who wants to build on online data-driven
I'm trying to achieve the following though with my intermediate JavaScript skills I'm not
First of all, I know how to write a basic/intermediate level makefile. In my
I am trying to reformat XML adding intermediate level node. Here is what I
I'm an intermediate-level programmer and I've been writing the code for several years in
I am intermediate with Javascript, but am not so familiar with Adobe's Extendscript. For
I am importing an intermediate result of query into a temp table for further
I'm a novice-to-intermediate JavaScript/jQuery programmer, so concrete/executable examples would be very much appreciated. My
I am a beginner-verging-on-intermediate rails developer that is working hard to improve my skills.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.