Expand Minimize

SPC058909: Consider to disallow primitive wrapper instances

Objects created from primitive wrappers, are not the same as the primitives themseleves, and used only internally

CheckId SPC058909
TypeName DisallowPrimitiveWrapperInstances
Severity Warning
Type JavaScriptFile

Bad Practice

var stringObject = new String('Hello world');var numberObject = new Number(33);var booleanObject = new Boolean(false);var stringObject = new String;var numberObject = new Number;var booleanObject = new Boolean;

Good Practice
var text = String(someValue);var num = Number(someValue);var object = new MyString();

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.