Snap.is(o, type)

typeof运算符另外一种更好的替代表现形式。


参数
  • o 类型任意。可以是任意对象或基本类型。
  • type 字符串。类型名称,如string, function, number等。

返回值

布尔值。如果给定值与给定类型匹配,则返回true.


使用
console.log(Snap.is(Math.random(), "number"));    // true