Object.inspect(obj) -> String
返回 obj
针对调试的字符串表现形式。
undefined
和 null
被表示为代表自身的字符串。inspect
方法:如果有,则调用这个方法,否则,调用 toString
方法。Prototype 为许多类型提供了 inspect
方法——不论是内建的类型还是库自定义的类型。例如 String、Array、Enumerable
和 Hash,这些方法试图从开发人员的角度出发, 为它们所属的类型提供更为有意义的字符串描述形式。
Object.inspect()
// -> 'undefined'
Object.inspect(null)
// -> 'null'
Object.inspect(false)
// -> 'false'
Object.inspect([1, 2, 3])
// -> '[1, 2, 3]'
Object.inspect('hello')
// -> "'hello'"