You may have heard of the book JavaScript: The Good Parts (Yahoo Press, December 2008) by Douglas Crockford. The name, obviously, implies that JavaScript has bad parts, too. The equality operator ==
is one aspect of JavaScript that is considered a bad part. Crockford writes in this book:
“JavaScript has two sets of equality operators:
===
and!==
, and their evil twins==
and!=
. The good ones work the way you would expect. If the two operands are of the same type and have the same value, then===
producestrue
and!==
producesfalse
. The evil twins do the right thing when the operands are of the same type, but if they are of different types, they attempt to coerce the values. The rules by which they do that are complicated and unmemorable.”
So the problem with the ==
operator is that it performs unexpected and complicated type conversions. For this reason, it is recommended that you always use ===
and never use ==
.
Object.is
is yet a new addition to JavaScript that tests for equality. It behaves like the ===
operator, with two exceptions: Contrary to the ===
operator, it treats +0
and -0
as not equal, and it treats NaN
and Number.NaN
as equal. Otherwise, it behaves like ===
. In other words, it returns true if both operands are undefined
, both are null
, both are true
or false
, both are strings with the same length and the same characters, both are the same object, or both are numbers with the same value.
Here are a few examples:
Object.is("hi", "hi"); // true
Object.is(undefined, null); // false
Object.is("", false); // false
Object.is(+0, -0); // false
+0 === -0; // true
Object.is(NaN, Number.NaN); // true
Number.NaN === NaN; // false
It is evident that Object.is
is the best way to test for equality in JavaScript.
java programming good technology for every people.all kind of people to know important about java programming....thank you sir for your good post..@ghasemkiani
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Great tip about is operator. Thanks for such a useful post.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
I have done level 4 of my game in ethereum. Alhamdulillah In the mean time I got a job. So i am very happy and also feeling sad because now i will get less time to connect with you. :(
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
So you're developing a game for ethereum. That's very interesting. Wishing you good luck and success!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Trying to do so sir. A game which will support ethereum.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
I have done core java , how much time will it take me to study basics of javascipt ?
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
JavaScript is very easy to learn, especially since you already know Java, you are familiar with its syntax. But you have to grasp two important concepts about JavaScript. First, the fact that JavaScript is a functional programming language and functions are first-class citizens here. Second, you should understand the prototype inheritance concept. I think these are the most important differences between JavaScript and Java. Besides, you should know that being a scripting language, JavaScript needs a host environment. It is usually run in the browser for client-side programming, but it is also widely used for server-side programming, notably with NodeJS. There is also Nashorn which is part of JDK 8 and later, which enables you to run JavaScript programs on top of Java. It's actually very cool. You can have the advantages of both Java and JavaScript all at once, and it is very fast too.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
love to read it. thanks@ghasemkiani:-)
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
How are you sir @ghasemkiani? Excellent tutorial program of Javascript.It is very helpful for me as I am learning in a training program on Web Designing.
Thanks @ghasemkiani for sharing.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thanks.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Excellent job sir. Thanks for the examples. It makes more easy to me to understand java programming.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Your post is so excellent
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Nice tips about java script. Thanks for sharing such tips.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
ahsant
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thank you sir for nice post........
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Good Post, thanks for sharing it.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Good to see your new experiment about JavaScript has worthy information always.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Assalamualaikum sir
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
I haven’t started java yet but I could pick one or two from you.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
thanks for the info
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Bisyar khub :)
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Carry on my dear sir&visit @pranto
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
great job dear and very well post. thank you for shering tihs post
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
good news. thanks for shairing
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
well done ghasemkiani!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
java programming good technology for every people.all kind of people to know important about java programming....thank you sir for your good post..@ghasemkiani
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Nice information about java
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
this is really helpful blog. excellent program of javascript. thank you so much for sharing this post.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
leran new thing from you. i have knowladge about c language
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
java is a useful program. thanks for sharing.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Informative post on java.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
a good post my good friend @ghasemkiani thanks for the information that has been shared with us
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thanks for sharing this post..I appreciate programing ..Thanks for share this post..
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
your posts help us to know about java programming.. Great job sir. Thank You and keep it up @ghasemkiani
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Carry on your activitys
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thanks for this post sharing.... i appreciate this programming...
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
very informative post...thanks sir
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
very miss you dear @ghasemkiani
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
@ghasemkiani Yes, JavaScript: The Good Parts is a great book. I just love your series of JavaScript. Keep sharing.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
thanks for sharing programming technology.
keep it up
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
am not heard
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Really good way to make equally command.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
This nice post i like it thanks for sharing this technology.. Best of luck..
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
i like reading book's thank you dear for sharing
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
i'm very sorry dear,, I did not come to the blog because I was in the examination,,,, very miss you dear,,
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thank you sir
You learnt me many thing about javascript in easily
Very very thank you
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Your blog always halpful
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
keep it up learning and exploring
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thanks, but i am a liltle confuse
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
very well post and great writing dear @ghasemkiani i like and support your post all time
keep it up dear
@ghasemkiani
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Great educational tips.Complete a series sir.
Thank you
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
i wanna knew more about it
Can i?
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
its so helpful post for me. thanks for sharing
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit