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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:22:18+00:00 2026-06-03T17:22:18+00:00

I have this slightly peculiar situation, a boolean statement I have is giving me

  • 0

I have this slightly peculiar situation, a boolean statement I have is giving me two different evaluations, in the alert and if operator.

var test = new Boolean(homePageNonActive && ((firstTime && homePageHash) || (!firstTime && !homePageHash)));
alert(homePageNonActive && ((firstTime && homePageHash) || (!firstTime && !homePageHash))); // GIVES ME FALSE
alert(test); // GIVES ME TRUE ??? WHY?

if(test){
    alert(homePageNonActive); // GIVES ME TRUE
    alert(firstTime); // GIVES ME TRUE
    alert(homePageHash); // GIVES ME FALSE
}
  • 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-03T17:22:20+00:00Added an answer on June 3, 2026 at 5:22 pm

    Everything seems to work just fine as long as you use boolean primitives.

    But the issue is that you are mixing Boolean objects (homePageHash) with boolean primitives (homePageNonActive and firstTime). The reason why test is "true" is because a "Boolean object false" is "truthy".

    Boolean object is not the same as a boolean primitive.

    Any object whose value is not undefined or null, including a Boolean object whose value is false, evaluates to true when passed to a conditional statement.

    var x = new Boolean(false),
        y = false; 
    
    if (x) {/*this code is executed*/}
    if (y) {/*this code is NOT executed*/} 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Similar question here but this is slightly different... I have two tables that I
I know this question has been done but I have a slightly different twist
This is a slightly original variation on a common problem. I have a fairly
OK, this is a slightly weird question. We have a touch-screen application (i.e., no
I have this page in which I slightly modified the jQuery autocomplete to make
I believe this question is slightly different than similar ones asked on here before
I have a DataGrid that looks like this (slightly simplified here): <asp:DataGrid ID=grdQuotas runat=server
I know similar questions have been asked before but i think this is slightly
I'm following this [slightly old tutorial for 2d java games here][1]. I have a
Have this query: SELECT HOUR( DATE ) AS hr, COUNT( * ) AS cnt

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.