Javascript 反射 - 通用 toString
现在,当我将自己的对象放入警报功能时,我看到
[对象对象]
即是无意义的信息。有没有办法使用反射来获取所有字段以及这些字段的值?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
JSON.stringify
通常是内置的,可以序列化您传递给它的大多数对象。也就是说,您可能应该只使用调试器或 console.log,而不是发出警报。
JSON.stringify
is often times builtin and can serialize most objects you pass to it.That said, you should probably just use a debugger or console.log instead of alert-ing things.
这是其中之一。但最好使用
console.log()
然后使用alert
Here is one of many. But better to use
console.log()
thenalert
当然,也许像
编辑::注意这只是一个愚蠢的小例子。
sure, maybe something like
Edit :: Note this is just a silly little example.