JavaScript Math toSource() 方法


定义和用法

toSource() 方法返回表示对象源代码的字符串。

注意: 该特性是非标准的,请尽量不要在生产环境中使用它!

语法
  1. object.toSource()

提示和注释

注释:该方法在 Internet Explorer 中无效。


实例

下面的例子向您展示 toSource() 方法的用法:

  1. <html>
  2. <body>
  3. <script type="text/javascript">
  4. function employee(name,job,born)
  5. {
  6. this.name=name;
  7. this.job=job;
  8. this.born=born;
  9. }
  10. var person=new employee("埃隆 马斯克","企业家",1981);
  11. document.write(person.toSource());
  12. </script>
  13. </body>
  14. </html>

输出:

分类导航