DEV Community 👩‍💻👨‍💻

VICTOR OMONDI
VICTOR OMONDI

Posted on

Check if key exists in Dictionary/Object in Python vs Javascript

Python

dict = { 'platform': 'telegram' }

if 'platform' in dict:
 # do something
Enter fullscreen mode Exit fullscreen mode

Javascript

let obj ={ platform: 'telegram' }

if(obj['platform']){

   // do something

}
Enter fullscreen mode Exit fullscreen mode

Top comments (2)

Collapse
 
waylonwalker profile image
Waylon Walker

❤️ python

Build Anything...


Use any Linode offering to create something for the DEV x Linode Hackathon 2022. A variety of prizes are up for grabs, inculding $1,000 USD. 👀

Join the Hackathon <-