Question: Python's get method for dictionaries lets me specify what should be returned if a key doesn't exist. For my current case I want a dictionary returned. How do I do this in Javascript?

Answer: 
With modern javascript you can use the [nullish coalescing operator `??`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing_operator)

```
const result = obj[key] ?? default;

```

This will return the default value if `key` doesn't exist in `obj`. It will also return the default in cases like `{myKey: undefined}` or `{myKey: null}`, which may or may not be the desired behavior.
JavaScript has no helper feature to do that. You need to test explicitly.

```
if ("myProperty" in myObject) {
    return { another: "object" };
} else {
    return myObject.myProperty;
}

```

You can use a ternary operator to do the same thing with less code.

```
return ("myProperty" in myObject) ? myObject.myProperty : { another: "object" };

```