Expand Minimize

Consider the use of a Namespace registration method, instead of object chains

Warning, do not declare code in the global namespace directly. Instead consider using the $_global_ namespace pattern with a Namespace registration method, this will ensure correct execution with the MDS garbage collector

CheckId SPC038902
TypeName ConsiderUseOfNamespaceRegistration
Severity Warning
Type JavaScriptFile

Bad Practice

var Global = Global || {};
Global.Child = Global.Child || {};
Global.Child.ChildOfChild = Global.Child.ChildOfChild || {};

Good Practice
// Method accepts whole namespace chain, registers Namespaces and creates objects

Disclaimer: The views and opinions expressed in this documentation and in SPCAF do not necessarily reflect the opinions and recommendations of Microsoft or any member of Microsoft. SPCAF and RENCORE are registered trademarks of Rencore. All other trademarks, service marks, collective marks, copyrights, registered names, and marks used or cited by this documentation are the property of their respective owners.