Defines a static property on a constructor if it does not already exist, or if the existing property is writable or configurable.
Array
Map
The constructor type (e.g., typeof Array).
typeof Array
The constructor object on which to define the static method.
The name of the static method to define.
The function to assign as the static method.
defineStaticIfNotExists(Array, 'range', function(start: number, end?: number) { // implementation}); Copy
defineStaticIfNotExists(Array, 'range', function(start: number, end?: number) { // implementation});
To forcefully replace an existing property, delete it first or use Object.defineProperty directly.
Object.defineProperty
Defines a static property on a constructor if it does not already exist, or if the existing property is writable or configurable.
Array,Map).