Skip to content

Instantly share code, notes, and snippets.

@wizard04wsu
wizard04wsu / VBArray.vbs
Last active July 1, 2020 17:57
VBScript or VBA array functions
Function getUBound(arr)
getUBound = -1
On Error Resume Next
getUBound = UBound(arr)
On Error GoTo 0
End Function
Function getLength(arr)
getLength = getUBound(arr) + 1
End Function
@wizard04wsu
wizard04wsu / isType.js
Last active August 27, 2021 17:13
Improved JavaScript type testing - Future revisions will be at https://github.com/wizard04wsu/javascript-type-testing
/**
* A more robust 'typeof'.
* https://gist.github.com/wizard04wsu/8055356
*
*
* For each of the type testing methods, the only parameter is the item to be tested. These methods do not perform coercion.
*
* is(o) - Returns the item's type.
* - NaN is considered its own type (instead of a number), since it essentially represents something that cannot be converted to a number.
* - For objects, the type of the object is given instead of just 'object' (e.g., 'Array').