当前位置: 移动技术网 > IT编程>开发语言>JavaScript > 简介JavaScript中Boolean.toSource()方法的使用

简介JavaScript中Boolean.toSource()方法的使用

2019年08月03日  | 移动技术网IT编程  | 我要评论

 javascript boolean.tosource()方法返回表示对象的源代码的字符串。

注意:此方法不会在internet explorer中运行。
语法

boolean.tosource()

下面是参数的详细信息:

  •     na

返回值

返回表示对象的源代码的字符串。
例子:

<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})

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网