Namespacing patterns
No your code is correct.

!reference only throws a reference error if its not defined.

window is defined and window["not_defined"] just returns undefined for not defined variables.