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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:39:05+00:00 2026-05-26T22:39:05+00:00

I have a simple json parsed object that sometimes has a variable tt defined

  • 0

I have a simple json parsed object that sometimes has a variable tt defined and sometimes doesn’t.

For some reason jsonobject.tt == null returns correctly 1 or 0 based on whether tt is defined. jasonobject.tt === null just returns 0 regardless. I thought === was the thing to use to avoid issues.

What’s going on here?

  • 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-26T22:39:06+00:00Added an answer on May 26, 2026 at 10:39 pm

    === is the strict equality operator, it compares type as well as value. The value null is the Null Type that has exactly one value – null.

    Undefined is the Undefined Type, which also has only one value – ‘undefined’.

    When using the strict equality operator, null !== undefined because they are different types (see step 1 of the Strict Equality Comparison Algorithm, ECMA-262 § 11.9.6).

    == is the equality operator. Comparisons using == use the Abstract Equality Comparison Algorithm (ECMA-262 § 11.9.3), which includes:

    1. If Type(x) is the same as Type(y), then …
    2. If x is null and y is undefined, return true.
    3. If x is undefined and y is null, return true.

    So null == undefined returns true by definition. Strictly, testing for the presence of a property (regardless of its value), should use hasOwnProperty:

    if (jsonobject.hasOwnProperty('tt')) {
      // property exists
    }
    

    however in practice there isn’t much difference to a strict test for undefined:

    if (jsonobject.tt === undefined) 
    

    because whether the property exists and has a value of undefined or hasn’t been defined at all is usually equivalent. Using === also means that the above will return false if tt exists but has been assigned a value of null.

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

Sidebar

Related Questions

I have an iPhone application that pulls some JSON data from a server and
I have some web services that receive JSON data send by jquery method. But
I have a web service that uses Python's SimpleJSON to serialize JSON, and a
I have simple win service, that executes few tasks periodically. How should I pass
I have simple HTML code with some JavaScript. It looks like: <html> <head> <script
I have some python code for Google App Engine that responds with the string
I have a serialized JSON String (chef role definition actually) and it has a
A simple question I'm sure, but I can't figure it out. I have some
I have a simple view that I'm using to experiment with AJAX. def get_shifts_for_day(request,year,month,day):
I have written a very simple test application that creates a websocket and parses

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.