loading...

Object looping in Python vs Javascript

victoromondi1997 profile image VICTOR OMONDI ・1 min read

Python

obj = {
    'name': 'Victor'
}

for key in obj:
    print("key: %s, value: %s" % (key, obj[key]))

Javascript:

let obj = {
    name: 'Victor'
}

for (key in obj) {
    console.log(`Key: ${key}, value: ${obj[key]}`);
}

Discussion

pic
Editor guide