Primitives are not objects. When you call a method on them they are temporarily wrapped in an object and unwrapped when the method is executed. Answer from sateeshsai on reddit.com
🌐
Vaia
vaia.com › javascript primitive data types
Javascript Primitive Data Types: Understanding & Examples
JavaScript primitive data types are the simplest forms of data, representing a single value, which include Number, String, Boolean, Null, Undefined, Symbol, and BigInt. Understanding these types is essential for efficient coding, as they are immutable and stored directly in the location that ...
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Glossary › Primitive
Primitive - Glossary | MDN
July 11, 2025 - In JavaScript, a primitive (primitive value, primitive data type) is data that is not an object and has no methods or properties. There are 7 primitive data types:
Discussions

Everything in JavaScript is an object...what about primitive data types?
Primitives are not objects. When you call a method on them they are temporarily wrapped in an object and unwrapped when the method is executed. More on reddit.com
🌐 r/learnjavascript
36
57
June 11, 2022
Confusion between Objects and primitive data types in Js
Now, cat is a variable of data type of object, and the object data represents the different key/value pairs (propreties), or the cat is an object? It's the same thing. Technically cat is a variable, and it holds an object (to be even more technical, it holds a reference to an object, but that's not the point). Saying "cat is an object" is a fairly common colloquial way to describe a variable and its type. For instance... let x = 1; I might say "x is a number". It's actually a variable that holds a number, but programmers are going to understand that's what I meant. More on reddit.com
🌐 r/learnprogramming
5
1
May 5, 2022
What is the difference between primitive and non-primitive data types? When are both used? Can you use them synonymously?
You can see what data types are primitives here on MDN: https://developer.mozilla.org/en-US/docs/Glossary/Primitive Technically, the differences can be subtle, but the big difference is that primitives are immutable, meaning you can't add to or modify properties within them like you can with objects. While you can have objects that are also immutable, primitives are always immutable. If you ever need to change a primitive value, it always has to be reassigned. It can't be modified. Primitives also generally represent a low-level value, not something complex. Things like numbers, strings and booleans make up primitives while more complex types like Dates and Arrays are defined by objects. Most primitives also have object variations of themselves. For example you can have the primitive number 5 or the number object new Number(5). However, you should almost always avoid the object version of primitive types and stick to using their primitive values. More on reddit.com
🌐 r/learnjavascript
4
1
April 11, 2023
If string is a primitive then why does it list a bunch of methods when I print out it's prototype?
Same docs answer this question imo: Most of the time, a primitive value is represented directly at the lowest level of the language implementation. All primitives are immutable; that is, they cannot be altered. It is important not to confuse a primitive itself with a variable assigned a primitive value. The variable may be reassigned to a new value, but the existing value can not be changed in the ways that objects, arrays, and functions can be altered. The language does not offer utilities to mutate primitive values. Primitives have no methods but still behave as if they do. When properties are accessed on primitives, JavaScript auto-boxes the value into a wrapper object and accesses the property on that object instead. For example, "foo".includes("f") implicitly creates a String wrapper object and calls String.prototype.includes() on that object. This auto-boxing behavior is not observable in JavaScript code but is a good mental model of various behaviors — for example, why "mutating" primitives does not work (because str.foo = 1 is not assigning to the property foo of str itself, but to an ephemeral wrapper object). More on reddit.com
🌐 r/learnjavascript
9
10
November 13, 2022
People also ask

What are the different types of primitive data types in JavaScript?
JavaScript has seven primitive data types: String, Number, Boolean, Undefined, Null, Symbol, and BigInt.
🌐
vaia.com
vaia.com › javascript primitive data types
Javascript Primitive Data Types: Understanding & Examples
How are JavaScript primitive data types stored in memory?
JavaScript primitive data types, which include numbers, strings, booleans, null, undefined, and symbols, are stored directly in the stack, because they are immutable and have a fixed size. This allows for efficient access and manipulation as they are stored by value.
🌐
vaia.com
vaia.com › javascript primitive data types
Javascript Primitive Data Types: Understanding & Examples
How do JavaScript primitive data types differ from reference types?
JavaScript primitive data types are immutable and stored by value, meaning each variable holds its own data copy. Reference types, like objects and arrays, are mutable and stored by reference, meaning variables point to the actual data location, allowing shared and modified data across different references.
🌐
vaia.com
vaia.com › javascript primitive data types
Javascript Primitive Data Types: Understanding & Examples
🌐
Edureka
edureka.co › blog › data-types-in-javascript
What are the Different Data Types in JavaScript - Edureka
February 11, 2025 - The Primitive Data types in JavaScript include Number, String, Boolean, Undefined, Null and Symbol.
🌐
JavaScript.info
javascript.info › tutorial › the javascript language › data types
Methods of primitives
June 12, 2022 - There are 7 primitive types: string, number, bigint, boolean, symbol, null and undefined.
🌐
DEV Community
dev.to › carlosrafael22 › back-to-the-basics-primitive-and-object-types-in-javascript-18c2
Back to the basics: Primitive and Object types in Javascript - DEV Community
March 29, 2021 - For string primitive there is String object, for number primitive there is Number, and so there are Boolean, BigInt and Symbol. Javascript automatically converts the primitives to their corresponding objects when a method is to be invoked.
🌐
W3Schools
w3schools.com › js › js_datatypes_primitives.asp
JavaScript Primitive Data Types
A JavaScript variable can hold 8 types of data. 7 Primitive types or an Object type.
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › primitive-and-non-primitive-data-types-in-javascript
Primitive and Non-primitive data-types in JavaScript - GeeksforGeeks
Primitive data types are the built-in data types provided by JavaScript. They represent single values and are not mutable.
Published   July 23, 2025
🌐
Reddit
reddit.com › r/learnjavascript › everything in javascript is an object...what about primitive data types?
r/learnjavascript on Reddit: Everything in JavaScript is an object...what about primitive data types?
June 11, 2022 -

I learned that everything in JS is an object and at first, I assumed this meant EVERYTHING.

This idea made complete sense when I considered all the build-in methods of both primitive data types and reference data types. I also understand that primitive data types are stored in global/local memory and reference data types are stored in the heap. But I was recently told that primitive data types aren't objects which is why they are stored in global memory vs the heap.

If primitive data types aren't objects, how do they have built-in methods that are called upon them?

Furthermore, if I was given the wrong info, and primitive data types are in fact objects, what do their key-value pairs look like under the hood. I should add I understand the key-values pairs of normal objects, arrays, and functions. If strings were objects, I would assume their key-value pair would be like arrays but then I am totally lost when it comes to numbers and Boolean values.

Can someone help explain what I am clearly missing? I have scoured the net and asked other devs but so far no one seems to know.

EDIT - Thank you to everyone who replied. I now have a deeper understanding, new words to google, and more resources to read.

Top answer
1 of 9
40
Primitives are not objects. When you call a method on them they are temporarily wrapped in an object and unwrapped when the method is executed.
2 of 9
30
Each value in JavaScript is either a primitive value or an object. Primitive values are ( see ECMAScript language specification ): undefined null booleans numbers bigints symbols strings All other values are objects. In practice, there are not many differences between primitive values and objects. The main ones are: Primitive values are compared by value, immutable by default, normally categorized via typeof Objects are compared by reference, mutable by default, normally categorized via instanceof All primitive types (except for the types of undefined and null) have associated wrapper classes: Booleans have the wrapper class Boolean. Numbers have the wrapper class Number. Etc. These wrapper classes have two main purposes: First, when called as functions, they convert values to their primitive types: > Number('123') 123 Second, they provide properties for primitive values: > 1.5.toString === Number.prototype.toString true Internally, the language specification temporarily wraps primitive values in order to look up properties. However, implementations can optimize looking up primitive properties and avoid or delay wrapping. Wrapping means invoking the constructor of the wrapper class: > typeof 'abc' // string (primitive value) 'string' > typeof new String('abc') // wrapped string (object) 'object' > typeof 123 // number (primitive value) 'number' > typeof new Number(123) // wrapped number (object) 'object' If we invoke a method on a primitive value p, then this is p in strict mode and a wrapped version of p in non-strict mode: String.prototype.getStrictThis = function () { 'use strict'; return this; }; // We use `new Function` to ensure that this code is in non-strict mode String.prototype.getSloppyThis = new Function(` return this; `); console.log(typeof 'abc'.getStrictThis()); // 'string' console.log(typeof 'abc'.getSloppyThis()); // 'object' If you want to read more about how exactly wrapper classes provide methods for primitive values, you can read this blog post where I explore the language specification: https://2ality.com/2022/03/properties-of-primitives.html
🌐
Medium
medium.com › @zachlandis91 › javascript-primitive-data-types-for-beginners-17498641d2d3
JavaScript Primitive Data Types (For Beginners) | by Zach Landis | Medium
March 28, 2023 - The primitive types include: Number: This data type represents a numerical value. It can be an integer or a floating-point number.
🌐
freeCodeCamp
freecodecamp.org › news › javascript-assigning-values-vs-assigning-references
JavaScript Primitive Values vs Reference Values – Explained with Examples
September 11, 2024 - Understanding the difference between ... between values and references in JavaScript. ... Primitive values are data that are stored directly in a variable....
🌐
CodeWithHarry
codewithharry.com › tutorial › primitive-and-objects
Data Types: Primitives and Objects | JavaScript Tutorial | CodeWithHarry
That’s why primitives are considered immutable — their actual values can’t be altered once they exist. Objects in JavaScript are more powerful and flexible. They can store multiple pieces of data and represent real-world entities like users, cars, or products. ... Keys are usually strings. Values can be any type (including other objects or primitives).
🌐
BrainStation®
brainstation.io › learn › javascript › data-types
JavaScript Data Types (2026 Tutorial & Examples) | BrainStation®
February 4, 2025 - Null in JavaScript represents an unknown or empty value. The undefined data type represents a variable that has not been assigned a value. BigInt can represent integers with arbitrary precision, allowing you to store and operate on larger numbers beyond the integer limit. If a value has the symbol data type, it is an immutable and unique primitive value.
🌐
WsCube Tech
wscubetech.com › resources › javascript › data-types
JavaScript Data Types: Primitive & Non-Primitive With Examples
November 5, 2025 - Learn about JavaScript data types: Primitive & Non-Primitive with examples. Explore strings, numbers, objects, arrays, and more in this comprehensive guide.
🌐
CodeSweetly
codesweetly.com › javascript-primitive-data-type
Primitive Data Type in JavaScript – Explained with Examples | CodeSweetly
A JavaScript primitive data type is any plain value used to program a webpage. Examples are Number, Boolean, String, Null, and BigInt.
🌐
Scaler
scaler.com › home › topics › what are non-primitive data types in javascript?
Non-primitive data types in Javascript | Scaler Topics
May 4, 2023 - Let's compare a string "scaler" using the match(regexp) method in JavaScript, and find out if the regexp pattern is present in this string or not. ... Explanation: We have created a RegExp variable regexp with scale pattern/string and i as the modifier that represents case insensitive matching. When we compare this pattern with the string scaler using the match() method, we get the result string that we have printed on the HTML output page. There are seven primitive data types in JavaScript:
🌐
W3Schools
w3schools.com › js › js_datatypes.asp
JavaScript Data Types
A JavaScript variable can hold 8 types of data. 7 Primitive Data Types and 1 Object Data Type. The Object data type can hold many different object types.
🌐
Mozilla
developer.mozilla.org › en-US › docs › Web › JavaScript › Guide › Data_structures
JavaScript data types and data structures - JavaScript | MDN
For symbols and BigInts, JavaScript has intentionally disallowed certain implicit type conversions. All types except Object define immutable values represented directly at the lowest level of the language. We refer to values of these types as primitive values.
🌐
33jsconcepts
33jsconcepts.com › concepts › primitive-types
Primitive Types - 33 JavaScript Concepts
January 7, 2026 - JavaScript has exactly seven primitive types: string, number, bigint, boolean, undefined, null, and symbol. As defined by the ECMAScript specification, these are the fundamental building blocks of all data in JavaScript — everything else is ...