is-symbol
Determine if a value is Symbol
install
npm i @silen/is-symbol
api
declare function isSymbol(val: any): boolean;
usage
const { isSymbol } = require('@silen/is-symbol');
// or
import { isSymbol } from '@silen/is-symbol';
console.log(isSymbol(new Buffer(4)));
console.log(isSymbol(Buffer.alloc(4)));
console.log(isSymbol(undefined));
console.log(isSymbol(null));
console.log(isSymbol(''));
console.log(isSymbol(true));
console.log(isSymbol(0));
console.log(isSymbol(1));
console.log(isSymbol(1.0));
console.log(isSymbol('string'));
console.log(isSymbol({}));
console.log(isSymbol(function foo() {}));
console.log(isSymbol(Symbol()));
console.log(isSymbol(new Set));
console.log(isSymbol(new Map));
console.log(isSymbol(new WeakMap));
console.log(isSymbol(new WeakSet));
// or
console.log(window.Type.isSymbol(new WeakSet));
This is a demo for testing the usage of isSymbol
from @silen/is-symbol
module. You can try the others and do likewise.
others
- type
- isArray
- isUndefined
- isNull
- isBoolean
- isBuffer
- isArrayBuffer
- isFormData
- isArrayBufferView
- isString
- isNumber
- isObject
- isPlainObject
- isDate
- isArguments
- isFile
- isBlob
- isFunction
- isRegExp
- isInt8Array
- isUint8Array
- isUint8ClampedArray
- isInt16Array
- isUint16Array
- isInt32Array
- isUint32Array
- isFloat32Array
- isFloat64Array
- isError
- isPromise
- isSet
- isWeakSet
- isMap
- isWeakMap
- isStream
- isURLSearchParams