JavaScript String valueOf() Tutorial

In this section, we will learn what the valueOf() method is and how to use it in JavaScript.

JavaScript String valueOf() Method

The `valueOf()` method is used to return the primitive value of a `String` object.

Note: Usually this method is called internally by the execution engine and so we don’t need to call it explicitly.

JavaScript String valueOf() Syntax


String valueOf() Method Parameters:

The method does not take any argument.

String valueOf() Method Return Value:

The return value of the `valueOf()` method is the primitive value of the target `String` object.

Example: using String valueOf() method in JavaScript

const str = new String("Hello World!");




Hello World!

Hello World!

Leave a Reply