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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:43:16+00:00 2026-06-10T14:43:16+00:00

I was reading a good book on JavaScript. It started with: Boolean type take

  • 0

I was reading a good book on JavaScript.

It started with:

Boolean type take only two literal values: true and false. These are distinct from numeric values, so true is not equal to 1, and false is not equal to 0.

However, I observed following:

if(1==true)
  document.write("oh!!! that's true");  //**this is displayed**

I know, that every type in JavaScript has a Boolean equivalent.

But then, what’s the truth?

  • 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-10T14:43:17+00:00Added an answer on June 10, 2026 at 2:43 pm

    It’s true that true and false don’t represent any numerical values in Javascript.

    In some languages (e.g. C, VB), the boolean values are defined as actual numerical values, so they are just different names for 1 and 0 (or -1 and 0).

    In some other languages (e.g. Pascal, C#), there is a distinct boolean type that is not numerical. It’s possible to convert between boolean values and numerical values, but it doesn’t happen automatically.

    Javascript falls in the category that has a distinct boolean type, but on the other hand Javascript is quite keen to convert values between different data types.

    For example, eventhough a number is not a boolean, you can use a numeric value where a boolean value is expected. Using if (1) {...} works just as well as if (true) {...}.

    When comparing values, like in your example, there is a difference between the == operator and the === operator. The == equality operator happily converts between types to find a match, so 1 == true evaluates to true because true is converted to 1. The === type equality operator doesn’t do type conversions, so 1 === true evaluates to false because the values are of different types.

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

Sidebar

Related Questions

I started reading JavaScript: The Good Parts book and became confused at first pages
I am reading about closures in Javascript: The Good Parts book. There is following
I just started reading on Douglas Crockford's Javascript The Good parts where he explains
I am reading the book Javascript: The good parts. Now I am reading chapter
I remember reading in Douglas Crockford's Javascript the Good Parts book that there is
I am currently reading the book Javascript: The Good Parts and was playing with
I'm reading Douglas Crockford's book JavaScript: The Good Parts. I can't understand the sentence
Javascript: The Good Parts is a great book. Often I find myself reading passages
So I'm reading The Art & Science of Javascript, which is a good book,
I'm reading the book Javascript: The Good Parts. And I'm confused by the following

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.