Logo

Programming-Idioms

History of Idiom 51 > diff from v37 to v38

Edit summary for version 38 by javajosh:
New JS implementation by user [javajosh]

Version 37

2019-09-26, 15:57:46

Version 38

2019-09-26, 17:07:19

Idiom #51 Check if map contains key

Determine whether map m contains an entry for key k

Illustration

Idiom #51 Check if map contains key

Determine whether map m contains an entry for key k

Illustration
Extra Keywords
table dictionary hash
Extra Keywords
table dictionary hash
Code
m.hasOwnProperty(k)
Comments bubble
This is like "k in m" except it doesn't check up the prototype chain, which is often not what people want.
Doc URL
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty
Demo URL
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty