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 6907085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:23:30+00:00 2026-05-27T08:23:30+00:00

I wasn’t sure how to express my question in a way that would make

  • 0

I wasn’t sure how to express my question in a way that would make it understandable, so I created a diagram below. The example is specific to JavaScript and Backbone.js, but I’m assuming this may also be regarded as just a general programming question as well.

I have an example of a Backbone collection and I’m having trouble understanding how the values are being passed around. I’m assuming that ‘task’ could just as easily be any arbitrary value like ‘taco’ or ‘horse’ and work just as well. I’m just wondering where and how ‘task’ is getting its value mapped to it.

Here is how I am looking at the problem and I’ve tried to recreate the path of my confusion below:

enter image description here

Here is the Task model if that helps:

var Task = Backbone.Model.extend({
  isComplete: function() {
    return this.get('completed_at') !== null;
  }
});
  • 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-05-27T08:23:31+00:00Added an answer on May 27, 2026 at 8:23 am

    The comparator function is called by underscore’s _.sortBy with array element as an argument, there is a ton of object creating and iteration going on for what essentially comes down to much faster native sort:

    someArrayOfTasks.sort( function( taskA, taskB ) {
    return taskA.dueDate < taskB.dueDate ? -1 :
           taskA.dueDate > taskB.dueDate ? 1 : 0;
    });
    

    Or a simpler example:

    [3,2,5,1,4].sort( function(a,b){
    return a-b;
    });
    //[1, 2, 3, 4, 5]
    
    [3,2,5,1,4].sort( function(a,b){
    return b-a;
    });
    //[5, 4, 3, 2, 1]
    

    The comparator function here gets its arguments from the sort function when it tries to resolve the sort order, the value that you return from the comparator determines in what order the array is sorted.

    I’d suggest normal sort over the backbone sort, as it’s 10x faster for me in chrome and easier to understand because the comparator function actually… compares: http://jsperf.com/underscore-sort-vs-normal-sort

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

Sidebar

Related Questions

I wasn't sure what the best way to word this question is but basically
I wasn't sure how to word the question but I would like to step
I wasn't even sure how to phrase this question. I'll give example content and
I wasn't sure what to title this question. Here's my goal: On page one,
Wasn't really sure how to word the question ... I have a project and
I wasn't sure how to word this question, so i'll just explain. I want
Wasn't sure how to write a good title for this question... :) I'm new
I wasn't sure if there was any good way of doing this. But I
I wasn't even sure how to title this right. I have a page that
I wasn't sure how to properly name this question, so if its better suited

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.