Loading...

JavaScript: !! vs hasOwnProperty vs "in" ???

3,340 views

Loading...

Loading...

Transcript

The interactive transcript could not be loaded.

Loading...

Rating is available when the video has been rented.
This feature is not available right now. Please try again later.
Published on Jun 7, 2016

http://WatchMeCode.net presents a WatchMeCode Q&A Episode.

In the past, I've often recommended people avoid the "!!" syntax in JavaScript, when checking to see if an object has an attribute. There are too many dangers with this syntax returning incorrect values.

Yet, I found myself reaching for this syntax, instinctively, because of its specific behavior.

Why? What value does this syntax provide? And what are the real differences between the !! syntax, Object.hasOwnProperty and the "attribute in obj" syntax?

In this episode of WatchMeCode Q&A, you'll find out exactly what these three syntax options do, and why each of them provides value in JavaScript.

Loading...

When autoplay is enabled, a suggested video will automatically play next.

Up next


to add this to Watch Later

Add to

Loading playlists...