관리 메뉴

Silver Library (Archived)

JS - wrapper object 본문

F2. Problem & Solving/Solving

JS - wrapper object

Chesed Kim 2021. 7. 7. 16:51
반응형

wrapper object (linked to prototype, heritage)

 

Caution: Some of them may be incorrect. Read at your own risk.

 

Note:

it is about the difference of 'where to store the value', and 'temporary', 'primitive'. 

Scanning for its object with the method I input to refer it accordingly.

 

This is kind of 'temporarily use the Primitive things like method.'

Once I approach to some method with Primitive,

 

 

const aqua = 'mizukami';

 

console.log(aqua.length); // 8

console.log(aqua.toUpperCase()); // MIZUKAMI

 

// Once calling it fisniehd (as wrapper object) and temporary object done his job, it will return the primitive one again.

console.log(typeof aqua); // string

 

This means, wrapper object will temporarily work like method since JS does implicitly create 'temporary object' inside prototype. In that prototype object, it has 'string type - wrapper object'. So, [[StringData]] will store the object which contains its string value.

 

My verdict:

This is somewhat specialised at 'temporarily let primitive to check/work out like how others dynamically use/apply method and do its job.

 

Note:

Wrapper objects

When we treat a primitive value like it was an object (i.e. by accessing properties and methods), JavaScript creates, under the hood, a wrapper to wrap this value and expose it as an object. The JS engine never reuses a wrapper object, giving them to the garbage collector right after a single use.

 

https://programmingwithmosh.com/javascript/javascript-wrapper-objects/

 

'F2. Problem & Solving > Solving' 카테고리의 다른 글

Linear & binary search with Python  (0) 2021.11.15
For in, For of 용도  (0) 2021.09.22
JS - switch  (0) 2021.07.06
[Node.js] - what is readline() modul?  (0) 2021.07.06
[JS] string includes() method  (0) 2021.07.06