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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:25:15+00:00 2026-05-27T16:25:15+00:00

JavaScript is non-strictly typed language as Java,for example. As we know, it converts value

  • 0

JavaScript is non-strictly typed language as Java,for example.

As we know, it converts value of result dependently upon context:

"2" + "3" results "23"

"2" * "3" results 6

This is quite clear and OK for understanding.

I just tried following expressions and got confused:

true && 1 results 1
true || 1 results true

Why the first gives Number and the second gives boolean?

Considering JavaScript conversion rules,I expect to get boolean values in both cases,due to boolean context of expression.

  • 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-05-27T16:25:16+00:00Added an answer on May 27, 2026 at 4:25 pm

    Check Douglas Crockford’s site, it says:

    The && operator is commonly called logical and. It can also be called
    guard. If the first operand is false, null, undefined, “” (the empty
    string), or the number 0 then it returns the first operand. Otherwise,
    it returns the second operand. This provides a convenient way to write
    a null-check:

    var value = p && p.name; /* The name value will only be retrieved from
    p if p has a value, avoiding an error. */
    

    The || operator is commonly
    called logical or. It can also be called default. If the first operand
    is false, null, undefined, “” (the empty string), or the number 0,
    then it returns the second operand. Otherwise, it returns the first
    operand. This provides a convenient way to specify default values:

    value = v || 10; /* Use the value of v, but if v doesn't have a value,
    use 10 instead. */
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Part of our java application needs to run javascript that is written by non-developers.
As far as I know, JavaScript is a general purpose language but mostly it
My iphone app called Google Local Search(non javascript version) to behave some search business.
Do any of the existing JavaScript frameworks have a non-regex replace() function, or has
For the purposes of debugging I need to make Richfaces use non-minified JavaScript. Is
Possible Duplicate: Javascript: strip out non-numeric characters from string String matching is headache for
Can non-local-returns be implemented in JavaScript, so that you could write something like: function
In other words, I want to do a regular, non-AJAX request, but using Javascript.
Is there a non-javascript way of changing the color of a label when the
I'm working with a third-party product. It uses JavaScript (non-JQuery) code on the page

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.