```javascript
obj.localStorage = window.localStorage ? true : false;
```

That should do it. Covering even weird cases like `0`, `false`, `NaN`, `""`, etc.

Also, a shortcut version could be:

```javascript
obj.localStorage = !!window.localStorage;
```