0

In my applications I have a main configuration document (object) that has some deep nesting. So I find myself typing config && config.Exports && config.Exports.accounting && config.Exports.accounting.thisIsWhatIWant a lot.

So my question is, in WebStorm, can I write config.Exports.accounting.thisIsWhatIWant and then use a shortcut key or right-click + some menu item to get it to auto expand these?

JoshJoe
  • 1,482
  • 2
  • 17
  • 35
  • Might consider using lodash which has `has()` and `get()` methods that take string paths as argument https://lodash.com/docs/4.17.4#get. or write a recursive helper function that takes in string path and walks through nesting levels – charlietfl Jan 26 '18 at 19:11
  • This can get ugly for deep nesting. Maybe consider looking at [javascript-test-for-existence-of-nested-object-key](https://stackoverflow.com/questions/2631001/javascript-test-for-existence-of-nested-object-key) as a cleaner alternative. – Skam Jan 26 '18 at 19:14
  • Yeah, I had looked at that in the past, but I didn't use it because it seemed to get in the way of tracking down any real problem I might run into. That is why I want to see if there is a way to auto complete from within the editor – JoshJoe Jan 26 '18 at 19:16

1 Answers1

0

Optional chaining wasn't around when I asked this question, but this is the answer.

https://fjolt.com/article/javascript-optional-chaining

JoshJoe
  • 1,482
  • 2
  • 17
  • 35