472,782 Members | 1,329 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,782 software developers and data experts.

Why null==undefined is true in javascript?

83 64KB
Why null==undefined is true in javascript?
Jul 29 '20 #1
2 4404
Banfa
9,065 Expert Mod 8TB
Because you are using the abstract equality operator (==) which allows the interpreter to coerce the types on either side of the comparison. Not sure which way it is trying to do it, either null is coerced into undefined (the type) or undefined is coerced into (object (the type of null)); I suspect the former. However once the coercion has happened the resulting values of the 2 sides are the same.

If you used the script equality operator (===) then the types have to be the same since the type of null is object and the type of undefined is undefined the operator will return false.
Jul 29 '20 #2
Naheedmir
62 32bit
== has rules for managing different types, and "null" and "undefined" are both things that mean "nothing," so having them be equal makes intuitive sense.
Aug 6 '20 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: IkBenHet | last post by:
Hello, I found this script to create a simple rich text form (http://programmabilities.com/xml/index.php?id=17): <html> <head> <title>Rich Text Editor</title> </head> <body>
14
by: Rich | last post by:
I am converting my enterprise solution from VS 2003 (.NET v1.1.4322) to VS 2005 (.NET v2.0.50727). The entire solution uses serveral technologies - Windows Server 2003 (AD, SQL Server 2000, IIS,...
7
by: jab3 | last post by:
Hello. I'm wondering if someone can answer something I'm sure has been answered a thousand times before. I am apparently just too dumb to find the answer. :) I've found information about the...
9
by: J de Boyne Pollard | last post by:
TWJava and JavaScript are two different animals. ;-) DHLOK Tom. DHL> DHLDefine the two. DHL> DHLTo me Java is the software that interprets and executes DHLJavaScripts and Java Applets. ...
5
by: =?iso-8859-1?q?Jean-Fran=E7ois_Michaud?= | last post by:
Hello, I've been trying to figure something out for the past few days and I can't seem to pinpoint what I'm doing wrong. I've been trying to call javascript from inside a <logic:equal>, but...
3
Bob Ross
by: Bob Ross | last post by:
I am trying to create a kind of back button for one my pop up pages. I am just using history.go(-1) for the button. I would like to only make the button visible when the user can go back. the...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.