javascript boolean.tosource()方法返回表示对象的源代码的字符串。
注意:此方法不会在internet explorer中运行。
语法
boolean.tosource()
下面是参数的详细信息:
返回值
返回表示对象的源代码的字符串。
例子:
<html> <head> <title>javascript tosource() method</title> </head> <body> <script type="text/javascript"> function book(title, publisher, price) { this.title = title; this.publisher = publisher; this.price = price; } var newbook = new book("perl","leo inc",200); document.write(newbook.tosource()); </script> </body> </html>
这将产生以下结果:
({title:"perl", publisher:"leo inc", price:200})
如对本文有疑问, 点击进行留言回复!!
通过if else和switch开关语句与随机数实现模拟猜拳小游戏
网友评论