- Part 1 – SP.Init.js and SP.ScriptUtility (this post)
- Part 2 – SP.ScriptHelpers
- Part 3 – Minimal Download Strategy
- Part 4 – Async Download Manager
- Part 6 – jQuery vs SharePoint
This class is the home to six very useful helper methods and one helper field.
- emptyString Field
- isNullOrEmptyString(str) Method
- isNullOrUndefined(obj) Method
- isUndefined(obj) Method
- truncateToInt(n) Method
- ScriptUtility() Constructor
Being able to infer the meaning from most of these is quite simple, however for clarification I will break down each one.
This method expects a string and returns a Boolean value. This method presumes the type is a string and checks against null, undefined and empty string.
This method accepts any object and uses type checking to see if the value has been defined, returning a Boolean value if there was a match.
Number(Inferred as Int) truncateToInt number
This method does nothing. It merely acts as a placeholder for the class name SP.ScriptUtility to hold the above methods.
SP.ScriptUtility houses several useful methods for use in your code; however this functionality is duplicated, so next time I will go into the first place this is duplicated. Again in SP.Init.js I will look at the undocumented SP.ScriptHelpers class.
Please feel free to comment, or ask questions. Also please subscribe for instant updates to our blog, where you can find out the latest and more unanswered SharePoint development questions from the SPCAF Team.
Read on Part 2 – SP.ScriptHelpers