자바스크립트 현재 원시값 종류는 8개다.
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.
변수와 변수에 할당되는 원시값 데이터들과 헷갈리지 말자.
변수 자체는 항상 다른 데이터 값을 재할당 받을수 있지만 원래 할당되어 있던 원시값은 변하지 않고 garbage collected 된다.
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).
자바스크립트안의 원시값들은 원래 매소드가 없지만 일방적으로 보자면 그런것도 아니다.
'foo'.includes("f") statement을 예로 들면 자바스크립트 엔진이 'foo'값을 그 string 독자적인 매소드가 아닌 wrapper 객체 String.prototype.includes() 매소드를 사용한다.
console.log("\"string\" type:", typeof "string"); // Logs: "string" type: string
console.log("7 type:", typeof 7); // Logs: 7 type is: number
console.log("7.5 type:", typeof 7.5); // Logs: 7.5 type is: number
console.log("true type:", typeof true); // Logs: true type: boolean
console.log("undefined type:", typeof undefined); // Logs: undefined type: undefined
console.log("null type:", typeof null); // Logs: null type: object
console.log("{} type:", typeof {}); // Logs: {} type: object
console.log("[] type:", typeof []); // Logs: [] type: object
console.log("function type:", typeof function(){}); // Logs: function type: function
사실 array / function도 객체이지만 일반 객체와는 다른 속성들이 있다.( function being callable, array는 length 속성이 있듯 etc)
https://medium.com/launch-school/javascript-weekly-data-types-and-mutability-e41ab37f2f95