Context sub-module
Used as a static object that has a bunch of properties describing the current JS environment and execution context.
Properties:
Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
hasDefine |
boolean | A global |
|||||||||||||||||||||||||||||||||
hasRequire |
boolean | A global |
|||||||||||||||||||||||||||||||||
hasExports |
boolean | A global |
|||||||||||||||||||||||||||||||||
hasModule |
boolean | A global |
|||||||||||||||||||||||||||||||||
hasModuleExports |
boolean | A |
|||||||||||||||||||||||||||||||||
hasSyncedExports |
boolean |
|
|||||||||||||||||||||||||||||||||
isNode |
boolean | An alias to |
|||||||||||||||||||||||||||||||||
isBrowser |
boolean | A web-browser environment detected. |
|||||||||||||||||||||||||||||||||
isWindow |
boolean | Is a browser |
|||||||||||||||||||||||||||||||||
isWorker |
boolean | Is a browser |
|||||||||||||||||||||||||||||||||
isServiceWorker |
boolean | Is a |
|||||||||||||||||||||||||||||||||
isDedicatedWorker |
boolean | Is a |
|||||||||||||||||||||||||||||||||
isSharedWorker |
boolean | Is a |
|||||||||||||||||||||||||||||||||
AMD |
object | Asynchronous Module Definition detection. Properties
|
|||||||||||||||||||||||||||||||||
CJS |
object | CommonJS detection. Properties
|
|||||||||||||||||||||||||||||||||
Node |
object | Node.js detection. Properties
|
|||||||||||||||||||||||||||||||||
Electron |
object | Electron detection. |
|||||||||||||||||||||||||||||||||
ok |
boolean | Electron environment detected. |
|||||||||||||||||||||||||||||||||
isDefault |
boolean | Is this the default app? |
|||||||||||||||||||||||||||||||||
isBundled |
boolean | Is this a bundled app? |
|||||||||||||||||||||||||||||||||
isMain |
boolean | Is this the main renderer frame? |
|||||||||||||||||||||||||||||||||
type |
string |
<nullable> |
|
||||||||||||||||||||||||||||||||
root |
object |
- Source:
Methods
(static) has(ns) → {boolean}
See if a root-level name is defined.
This adds a context.has.{name}
boolean property which caches the
result so it can be referred to directly.
In any JS environment with the Proxy
object (which honestly should
be all modern ones), you can simple do context.has.SomeObject
instead
of context.has('SomeObject')
and it will do the Right Thing™.
Parameters:
Name | Type | Description |
---|---|---|
ns |
string | The global function/class/object we're looking for. |
- Source:
Returns:
If that global name is defined or not.
- Type
- boolean