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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:47:48+00:00 2026-06-09T11:47:48+00:00

This following code is taken from Backbone.js Events#off() How can I simplify the IF

  • 0

This following code is taken from Backbone.js Events#off()

How can I simplify the IF part so it’s easy to understand ?

for (i = list.length - 2; i >= 0; i -= 2) {
    if (!(callback && list[i] !== callback || context && list[i + 1] !== context)) {
        list.splice(i, 2);
    }
}
  • 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-09T11:47:50+00:00Added an answer on June 9, 2026 at 11:47 am

    Some boolean maths:

    !(callback && list[i] !== callback || context && list[i + 1] !== context)
    !(!(!callback || list[i] === callback) || !(!context || list[i + 1] === context))
    (!callback || list[i] === callback) && (!context || list[i + 1] === context)
    

    I think the disjunctive normal form is much easier to understand than the negated conjunctive normal form.

    To make the single parts easier to understand, use speaking variable names (I don’t know the scope of this, you may find something better):

    var rightCallback = !callback || list[i] === callback;
    var rightContext = !context || list[i + 1] === context;
    if (rightCallback && rightContext) {…}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is this possible to do the following in ExpressionEngine: (code taken from here )
This may well have come up before but the following code is taken from
This is a bit different. The following code was taken from a javascript script.
I have the following C code to copy a linked list(taken from Stanford CS
The following code is taken from OpenWRT project. Can someone give an abstract description?
The following code is taken from much larger code but I believe that this
I'm having hard time understanding the following C# code. This code was taken from
The following code when compiled give this error I cannot understand why this is
Hi I have the following bubble sort algorithm (generic code taken from another site)
I have the following code (taken from actual script): $result=mysql_query($sql); while($row=mysql_fetch_assoc($result)) { $auth_token=$row['oauth_token']; $auth_token_secret=$row['oauth_token_secret'];

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.