Built-in javascript constructors?

JavascriptObject Oriented ProgrammingFront End Technology

Javascript has provided some built-in constructors. Those built-in functions include object(), string(), number, etc. We cannot include Math object in those built-in constructors because Math is a global object. The 'new' keyword cannot be used with Math.


In the following example, many built-in constructors were used and their types were displayed as shown in the output.

Live Demo

   var a = new Object();
   var b = new String();
   var c = new Number();
   var d = new Boolean();
   var e = new Array();
   var f = new RegExp();
      "a: " + typeof a + "</br>" +
      "b: " + typeof b + "</br>" +
      "c: " + typeof c + "</br>" +
      "d: " + typeof d + "</br>" +
      "e: " + typeof e + "</br>" +
      "f: " + typeof f + "</br>" 


a: object
b: object
c: object
d: object
e: object
f: object
Updated on 07-Aug-2019 13:48:16