Underscore.JS - isSymbol 方法



語法

_.isSymbol(object)

isSymbol 方法檢查物件是否為 Symbol。請參見以下示例 −

示例

var _ = require('underscore');

//Example 1: Check if argument passed is a Symbol
console.log(_.isSymbol(Symbol()));

//Example 2: Check if argument passed is a symbol
console.log(_.isSymbol('Test'));

將上述程式儲存在 tester.js 中。執行以下命令以執行該程式。

命令

\>node tester.js

輸出

true
false
underscorejs_comparing_objects.htm
廣告