Javascript反射 - 泛型toString [英] Javascript reflection - generic toString

查看:76
本文介绍了Javascript反射 - 泛型toString的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在,当我将自己的Object放入警报功能时,我看到

now when I put my own Object in alert function I see


[对象对象]

[Object object]

这是毫无意义的信息。是否有任何方法使用反射来获取这些字段的所有字段和值?

that is pointless information. is there any way using reflection to get all fields and values of those fields?

推荐答案

JSON.stringify 通常是内置的,可以序列化你传递给它的大多数对象。

JSON.stringify is often times builtin and can serialize most objects you pass to it.

也就是说,你应该只使用调试器或console.log而不是警告事物。

That said, you should probably just use a debugger or console.log instead of alert-ing things.

这篇关于Javascript反射 - 泛型toString的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆