toSource()

优质
小牛编辑
119浏览
2023-12-01

toSource 方法

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

语法:

  stringObject.toSource();

注:

该方法在 Internet Explorer 中无效。

示例:

  var Str = "hello graybobo",
      s = Str.toSource();

  console.log( s );
  console.log( typeof s );

结果:

  >>>
  (new String("hello graybobo"))
  string