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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:18:54+00:00 2026-05-31T01:18:54+00:00

var boolTrue = true; var randomObject; if (boolTrue) // this will fire if (randomObject)

  • 0
var boolTrue = true;
var randomObject;

if (boolTrue)
// this will fire

if (randomObject)
// this will fire, because the object is defined

if (!objectNotDefined)
// this will fire, because there is no defined object named 'objectNotDefined'

Coming from a C++ and C# background, I am very familiar with the basic if(expression) syntax. However, I think it is not very readable to have both expressions (true/false) and have object existence also being a expression. Because now if I see a function like below, i don’t know if the data coming in is an object (existence/undefined check) or a boolean.

function(data) {
   if (data)
      // is this checking if the object is true/false or if the object is in existence?
}

Is this just the way it is? I mean, is there anyway to easily read this? Also, where is this documented anywhere in the JS spec (curious)?

  • 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-31T01:18:55+00:00Added an answer on May 31, 2026 at 1:18 am

    In Javascript everything is “true” (or “truthy” to be more precise using Javascript parlance) except false, 0, undefined, null, NaN and empty string.

    To avoid confusion use:

     if (data === true) // Is it really true?
    

    and

    if (typeof data === 'undefined') // Is the variable undefined?
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

var clickable = ApplyClickableLinkToClass($j(.rc_blueBtn)); setTimeout(clickable, 1000); But if I call it like this there
var auditAgencyRecords = (from ag in db.Agencies join ara in db.AuditRuleAccounts on ag.Agency_Id equals
im requesting information from the instagram api in php like this: <?php $relation =
var q = 'SELECT * FROM stories_comments WHERE story_id=? AND user_id=? ORDER BY created_at
From the isset() docs : isset() will return FALSE if testing a variable that
var listOfStates = from n in _storageStates select n.tag; If n.tag is a string
var plugin = { Init: function() { this.UpdateUI(); if (this.Status() == 1) { ...
var MyObj = function(h,w){ this.height = h; this.width = w; } I would like
i ran into this wierd problem: the $myImg variable has been extracted from some
Can someone explain me why this: var_dump((bool) 1==2); returns bool(true) but var_dump(1==2); returns bool(false)

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.