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 (1)

Collapse
 
waylonwalker profile image
Waylon Walker

❀️ python