Do not do toString directly on method objects |
Do not do function.ToString() comparisons directly as they are handled differently in each browser, always assign to a variable first
CheckId | SPC018911 |
---|---|
TypeName | NoComparisonWithMethodResultToString |
Severity | CriticalError |
Type | JavaScriptFile |
Bad Practice
return funcCall().toString() === funcCall().toString();
Good Practice
var resultOne = funcCall();
var resultTwo = funcCall();
return resultOne.toString() === resultTwo.toString();
var resultTwo = funcCall();
return resultOne.toString() === resultTwo.toString();
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.