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

  • Home
  • SEARCH
  • 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 9066279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:41:58+00:00 2026-06-16T16:41:58+00:00

Possible Duplicate: javascript: plus symbol before variable obj.length === +obj.length in javascript While looking

  • 0

Possible Duplicate:
javascript: plus symbol before variable
obj.length === +obj.length in javascript

While looking at the source of underscore.js I came across this line (#79)

//some stuff
} else if (obj.length === +obj.length) {
//do stuff

I’m not 100% certain of whats going on here, can anyone explain the
purpose of the ‘+’ before the obj.length value?? Would the comparison
be identical if it just read:

} else if (obj.length === obj.length) {

The same type of comparison is made multiple times in underscore.js, so
I’m fairly certain it’s not a typo.

If anyone could point me to an article, or throw some correct terminology at me, I’d appreciate it :). Thanks!

  • 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-16T16:41:59+00:00Added an answer on June 16, 2026 at 4:41 pm

    It’s checking if the length property is numeric. When the unary + is applied, it will return the numeric representation of an object or NaN, which will be the basis for which the comparison will pass or fail. For the first case, if obj doesn’t have a length property it will be +undefined which will return NaN. And if obj.length is numeric, the condition will pass.

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

Sidebar

Related Questions

Possible Duplicate: JavaScript Variable inside string without concatenation - like PHP In PHP, double
Possible Duplicate: javascript object, access variable property name? I'm trying to call a method
Possible Duplicate: Google +1 Button not W3C compliant My javascript for google plus fails
Possible Duplicate: JavaScript numbers to Words I am looking for a method of getting
Possible Duplicate: Javascript - array.contains(obj) What's wrong with this: var zipCodes =(['90001','90002','90003']); Test if
Possible Duplicate: JavaScript Variable Scope I have a JavaScript function for HTML select options
Possible Duplicate: javascript object, access variable property name? I am messing around with JS,
Possible Duplicate: Javascript Variable Variables Javascript dynamic variable name Given several variables var myVar0;
Possible Duplicate: Javascript Variable Variables There's a really handy thing in PHP (that I'm
Possible Duplicate: Javascript Regex: How to put a variable inside a regular expression? I'm

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.