Are String Objects in JavaScript? Last Updated : 23 Jul, 2025 Comments Improve Suggest changes 1 Likes Like Report Strings in JavaScript are one of the primitive data types, alongside numbers, booleans, null, undefined, bigint, and symbols. Unlike objects, primitives do not have methods or properties of their own. However, when you attempt to call a method or access a property on a string, JavaScript automatically wraps the string in a String object to provide access to methods. JavaScript let s = "hello"; console.log(typeof s); console.log(s.length); // Example with a number let x = 42; console.log(x.toString()); // Example with a boolean let y = true; console.log(y.toString()); /* Internal Working of primitives to be treeated as objects // Temporary wrapper object let temp = new String("hello"); console.log(temp.length); // 5 // The wrapper is discarded after use temp = null; */ Outputstring 5 42 true The String ObjectJavaScript has a built-in String object that can be explicitly used to create string objects. This is different from primitive strings. JavaScript const s = new String("Hello"); console.log(typeof s); Outputobject Key Differences Between Primitives and String ObjectsFeaturePrimitive StringString ObjectType"string""object"Memory EfficiencyMore efficientLess efficientUse CaseHighly used in creating stringRarely usedTip: Always prefer primitive strings for simplicity and performance.Why the Confusion?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. JavaScript const s = "Test"; console.log(s.constructor === String); Outputtrue Here, JavaScript implicitly wraps the string in a String object to access the .constructor property. Create Quiz Comment S souravsharma098 Follow 1 Improve S souravsharma098 Follow 1 Improve Article Tags : JavaScript Web Technologies javascript-string javascript-object JavaScript-Questions JavaScript Facts JavaScript-String-Questions +3 More Explore JavaScript BasicsIntroduction to JavaScript4 min readVariables and Datatypes in JavaScript6 min readJavaScript Operators5 min readControl Statements in JavaScript4 min readArray & StringJavaScript Arrays7 min readJavaScript Array Methods7 min readJavaScript Strings5 min readJavaScript String Methods9 min readFunction & ObjectFunctions in JavaScript5 min readJavaScript Function Expression3 min readFunction Overloading in JavaScript4 min readObjects in JavaScript4 min readJavaScript Object Constructors4 min readOOPObject Oriented Programming in JavaScript3 min readClasses and Objects in JavaScript4 min readWhat Are Access Modifiers In JavaScript ?5 min readJavaScript Constructor Method7 min readAsynchronous JavaScriptAsynchronous JavaScript2 min readJavaScript Callbacks4 min readJavaScript Promise4 min readEvent Loop in JavaScript4 min readAsync and Await in JavaScript2 min readException HandlingJavascript Error and Exceptional Handling6 min readJavaScript Errors Throw and Try to Catch2 min readHow to create custom errors in JavaScript ?2 min readJavaScript TypeError - Invalid Array.prototype.sort argument1 min readDOMHTML DOM (Document Object Model)8 min readHow to select DOM Elements in JavaScript ?3 min readJavaScript Custom Events4 min readJavaScript addEventListener() with Examples9 min readAdvanced TopicsClosure in JavaScript4 min readJavaScript Hoisting6 min readScope of Variables in JavaScript3 min readJavaScript Higher Order Functions7 min readDebugging in JavaScript4 min read Like