内置的javascript构造函数?
Javascript 提供了一些内置的构造函数。这些内置函数包括object()
,,string()
number等。我们不能在那些内置构造函数中包括Math 对象,因为Math 是全局对象。'new'关键字不能与Math一起使用。
示例
在以下示例中,使用了许多内置的构造函数,其类型如输出所示。
<html> <body> <script> var a = new Object(); var b = new String(); var c = new Number(); var d = new Boolean(); var e = new Array(); var f = new RegExp(); document.write( "a: " + typeof a + "</br>" + "b: " + typeof b + "</br>" + "c: " + typeof c + "</br>" + "d: " + typeof d + "</br>" + "e: " + typeof e + "</br>" + "f: " + typeof f + "</br>" ); </script> </body> </html>
输出结果
a: object b: object c: object d: object e: object f: object