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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:49:58+00:00 2026-06-06T04:49:58+00:00

Okay, here’s my short question: I know that === and !== operators will compare

  • 0

Okay, here’s my short question:

I know that === and !== operators will compare the types and then the values, and that == and != will cast the types and then just compare the values.

What about if(myVar) and if(!myVar)?

Is there any difference in the behavior from if(myVar == true) and if(myVar == 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-06T04:49:59+00:00Added an answer on June 6, 2026 at 4:49 am

    Yes, there is a difference. As you already mentioned, if you compare a value with ==, type conversion takes places.

    If the values are not of the same type, they will both be converted to either strings or numbers. If one of the values is a boolean and the other is not, both values will be converted to numbers.

    The comparison algorithm is defined in section 11.9.3 of the specification. The important step is here:

    7. If Type(y) is Boolean, return the result of the comparison x == ToNumber(y).

    So true is converted to a number first and later myVar will be converted to a number as well.


    If you only have if(myVar) though, then the value is converted to a boolean:

    2. If ToBoolean(GetValue(exprRef)) is true, then


    ToNumber [spec] and ToBoolean [spec] can return very different results.


    Note: If myVar is actually a boolean, then there is no difference between if(myVar == true) and if(myVar).

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

Sidebar

Related Questions

Okay here is what I'm trying to do: I have a model object that
Okay so here is the deal. As the question states, I'm trying to POST
Okay so here is the code that I am using function AddProducts($aTitle, $aDescription, $aPrice,
Okay here is a softball beginner WPF question. By default the background of the
Okay, here's my situation. I have a WPF app that I have created that
Okay so here my issue, I have a list of items that when a
Okay so here's the scenario: User is presented with form that contains file inputs.
Okay big brains here's something that's more of a challenge than a requirement. I
Okay, I'm confused here. I have a properties file with some SQL scripts that
Okay, two admissions here, one is I'm sure this question has been answered and

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.