Javascript String constructor

Introduction

The String constructor creates a new String object.

It performs type conversion when called as a function.

new String(thing)
String(thing) //converter function
  • thing - anything to be converted to a string.

String function and String constructor produce different results:

typeof String('Hello world'); // string
typeof new String('Hello world'); // object



PreviousNext

Related