30秒学会 JavaScript 片段 – isSymbol
Checks if the given argument is a symbol.
Use typeof
to check if a value is classified as a symbol primitive.
代码片段
const isSymbol = val => typeof val === 'symbol';
使用样例
isSymbol(Symbol('x')); // true
分享文章、钻研技术、改变生活!
Checks if the given argument is a symbol.
Use typeof
to check if a value is classified as a symbol primitive.
const isSymbol = val => typeof val === 'symbol';
isSymbol(Symbol('x')); // true