🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › String
String - JavaScript - MDN Web Docs
May 22, 2026 - The String object is used to represent and manipulate a sequence of characters. Strings are useful for holding data that can be represented in text form.
🌐
TutorialsPoint
tutorialspoint.com › javascript › javascript_strings_object.htm
JavaScript - Strings
The String object in JavaScript lets you work with a series of characters; it wraps JavaScript's string primitive data type with a number of helper methods. As JavaScript automatically converts between string primitives and String objects, you can
🌐
W3Schools
w3schools.com › jsref › jsref_obj_string.asp
JavaScript String Reference
HTML wrapper methods return a string wrapped inside an HTML tag. These are not standard methods, and may not work as expected. The HTML wrapper methods are deprecated in JavaScript.
🌐
C# Corner
c-sharpcorner.com › article › array-and-string-object-in-javascript
String Objects in JavaScript
March 17, 2023 - JavaScript String Object is a universal object that is used to store strings.
🌐
Tutorial Republic
tutorialrepublic.com › javascript-reference › javascript-string-object.php
JavaScript String Properties and Methods - Tutorial Republic
This chapter contains a brief overview of the properties and method of the global String object. The JavaScript String object is a global object that is used to store strings.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-strings
JavaScript Strings - GeeksforGeeks
... // Using Single Quote let s1 = 'abcd'; console.log(s1); // Using Double Quote let s2 = "abcd"; console.log(s2); The new String() constructor creates a string object instead of a primitive string.
Published   June 11, 2026
🌐
Study.com
study.com › computer science courses › introduction to javascript
Strings & Objects in JavaScript: Explanation & Examples | Study.com
... In JavaScript, objects are just like any other variables except that they can contain many values (called properties) and can have methods (like functions) that perform actions on those values.
🌐
O'Reilly
oreilly.com › library › view › learning-javascript › 0596527462 › ch04s03.html
The String Object - Learning JavaScript [Book]
October 17, 2006 - <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Exploring String</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body> <script type="text/javascript"> //<![CDATA[ var sObj = new String( ); var sTxt = sObj.concat("This is a ", "new string"); document.writeln(sTxt); //]]> </script> </body> </html> There is no known limit to the number of strings you can concatenate with the String concat method. However, I rarely use this myself; I prefer the String operators, such as the string concatenation operator (+). The properties and methods available with the String object are listed in Table 4-1.
Author   Shelley Powers
Published   2006
Pages   352
🌐
Medium
medium.com › @muhamedsalihseyedibrahim › javascript-the-strings-object-d423722ee4a
JavaScript — The Strings Object
July 7, 2023 - The String object in JavaScript represents a sequence of characters and provides various methods to work with strings. It serves as a wrapper for the primitive string data type and allows you to perform operations on strings easily.
Find elsewhere
🌐
Techotopia
techotopia.com › index.php › JavaScript_String_Object
JavaScript String Object - Techotopia
It provides a range of methods that can be used to perform a variety of string manipulation tasks (replacing parts of a string with different text, extracting fragments of a string, finding where a particular character appears in a string and much, much more).
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › are-string-objects-in-javascript
Are String Objects in JavaScript? - GeeksforGeeks
July 23, 2025 - The confusion arises because strings appear to have methods and properties like objects, but they are primitives. The temporary wrapping of primitives into String objects is what enables this behavior. ... Here, JavaScript implicitly wraps the string in a String object to access the .constructor property.
🌐
freeCodeCamp
forum.freecodecamp.org › curriculum help
Understanding strings as objects - Curriculum Help - The freeCodeCamp Forum
September 5, 2018 - I’m trying to better understand the internal structure of a string. In the following code, I initialize a string. To see what’s inside, I use Object.getOwnPropertyNames() and Object.values(). var str = 'hi'; console.log(Object.getOwnPropertyNames(str)); console.log(Object.values(str)); ...
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › String › String
String() constructor - JavaScript - MDN Web Docs
July 10, 2025 - The String() constructor creates String objects. When called as a function, it returns primitive values of type String. ... Note: String() can be called with or without new, but with different effects. See Return value. ... Anything to be converted to a string.
Top answer
1 of 12
186

JavaScript has two main type categories, primitives and objects.

var s = 'test';
var ss = new String('test');

The single quote/double quote patterns are identical in terms of functionality. That aside, the behaviour you are trying to name is called auto-boxing. So what actually happens is that a primitive is converted to its wrapper type when a method of the wrapper type is invoked. Put simple:

var s = 'test';

Is a primitive data type. It has no methods, it is nothing more than a pointer to a raw data memory reference, which explains the much faster random access speed.

So what happens when you do s.charAt(i) for instance?

Since s is not an instance of String, JavaScript will auto-box s, which has typeof string to its wrapper type, String, with typeof object or more precisely s.valueOf(s).prototype.toString.call = [object String].

The auto-boxing behaviour casts s back and forth to its wrapper type as needed, but the standard operations are incredibly fast since you are dealing with a simpler data type. However auto-boxing and Object.prototype.valueOf have different effects.

If you want to force the auto-boxing or to cast a primitive to its wrapper type, you can use Object.prototype.valueOf, but the behaviour is different. Based on a wide variety of test scenarios auto-boxing only applies the 'required' methods, without altering the primitive nature of the variable. Which is why you get better speed.

2 of 12
39

This is rather implementation-dependent, but I'll take a shot. I'll exemplify with V8 but I assume other engines use similar approaches.

A string primitive is parsed to a v8::String object. Hence, methods can be invoked directly on it as mentioned by jfriend00.

A String object, in the other hand, is parsed to a v8::StringObject which extends Object and, apart from being a full fledged object, serves as a wrapper for v8::String.

Now it is only logical, a call to new String('').method() has to unbox this v8::StringObject's v8::String before executing the method, hence it is slower.


In many other languages, primitive values do not have methods.

The way MDN puts it seems to be the simplest way to explain how primitives' auto-boxing works (as also mentioned in flav's answer), that is, how JavaScript's primitive-y values can invoke methods.

However, a smart engine will not convert a string primitive-y to String object every time you need to call a method. This is also informatively mentioned in the Annotated ES5 spec. with regard to resolving properties (and "methods"¹) of primitive values:

NOTE The object that may be created in step 1 is not accessible outside of the above method. An implementation might choose to avoid the actual creation of the object. [...]

At very low level, Strings are most often implemented as immutable scalar values. Example wrapper structure:

StringObject > String (> ...) > char[]

The more far you're from the primitive, the longer it will take to get to it. In practice, String primitives are much more frequent than StringObjects, hence it is not a surprise for engines to add methods to the String primitives' corresponding (interpreted) objects' Class instead of converting back and forth between String and StringObject as MDN's explanation suggests.


¹ In JavaScript, "method" is just a naming convention for a property which resolves to a value of type function.

🌐
Acid & Base
sceweb.sce.uhcl.edu › helm › WEBPAGE-Javascript › my_files › Object › Module-4 › module4page.html
Strings Object
The String object lets you work with a series of characters; it wraps Javascript's string primitive data type with a number of helper methods.
🌐
LaunchCode
education.launchcode.org › intro-to-web-dev-curriculum › stringing-characters-together › reading › string-objects › index.html
Strings as Objects :: Introduction to Web Dev
May 25, 2023 - We will learn quite a bit more ... functionality in useful, modular ways. The fact that strings are objects means that they have associated data and operations, or properties and methods as we will call them from now on....
🌐
Medium
therohantomar.medium.com › understanding-javascript-strings-primitive-vs-object-a65164c72b87
🧠Understanding JavaScript Strings: Primitive vs Object | by Therohantomar | Medium
January 15, 2025 - When you call a method on a primitive string, JavaScript temporarily wraps the string in a String object so that the method can be called. This is done automatically and behind the scenes, so it’s usually not something you need to worry about.
🌐
Scientech Easy
scientecheasy.com › home › blog › javascript string | string object, example
JavaScript String | String Object, Example - Scientech Easy
July 19, 2022 - In JavaScript, string is an object. Any variable whose value is a string is actually a string object.