How do primitive values get their properties?

This blog post is second in a series of two:

What are wrapper objects for primitive values?
How do primitive values get their properties?

JavaScript has two kinds of values:

primitive values (undefined, null, booleans, numbers, bigints, strings, sy…


This content originally appeared on 2ality – JavaScript and more and was authored by Dr. Axel Rauschmayer

This blog post is second in a series of two:

  1. What are wrapper objects for primitive values?
  2. How do primitive values get their properties?

JavaScript has two kinds of values:

  • primitive values (undefined, null, booleans, numbers, bigints, strings, symbols)
  • objects (all other values)

The ECMAScript specification states:

A primitive value is a datum that is represented directly at the lowest level of the language implementation.

However, despite this fact, we can still use primitive values (other than undefined and null) as if they were immutable objects:

> 'xy'.length
2

This blog post answers the following question:

How do primitive values get their properties?

We’ll look at:

  • Getting property values
  • Invoking property values (a.k.a. method calls)
  • Setting property values

Each time, we’ll first examine what’s going on via JavaScript code and then investigate how the language specification explains the phenomena.

Note that JavaScript engines only mimick the external behavior of the language specification. Some of what the spec does internally is not very efficient (e.g. wrapping primitive values) and often done differently in engines.

[Read rest of post]


This content originally appeared on 2ality – JavaScript and more and was authored by Dr. Axel Rauschmayer


Print Share Comment Cite Upload Translate Updates
APA

Dr. Axel Rauschmayer | Sciencx (2022-03-02T00:00:00+00:00) How do primitive values get their properties?. Retrieved from https://www.scien.cx/2022/03/02/how-do-primitive-values-get-their-properties/

MLA
" » How do primitive values get their properties?." Dr. Axel Rauschmayer | Sciencx - Wednesday March 2, 2022, https://www.scien.cx/2022/03/02/how-do-primitive-values-get-their-properties/
HARVARD
Dr. Axel Rauschmayer | Sciencx Wednesday March 2, 2022 » How do primitive values get their properties?., viewed ,<https://www.scien.cx/2022/03/02/how-do-primitive-values-get-their-properties/>
VANCOUVER
Dr. Axel Rauschmayer | Sciencx - » How do primitive values get their properties?. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/03/02/how-do-primitive-values-get-their-properties/
CHICAGO
" » How do primitive values get their properties?." Dr. Axel Rauschmayer | Sciencx - Accessed . https://www.scien.cx/2022/03/02/how-do-primitive-values-get-their-properties/
IEEE
" » How do primitive values get their properties?." Dr. Axel Rauschmayer | Sciencx [Online]. Available: https://www.scien.cx/2022/03/02/how-do-primitive-values-get-their-properties/. [Accessed: ]
rf:citation
» How do primitive values get their properties? | Dr. Axel Rauschmayer | Sciencx | https://www.scien.cx/2022/03/02/how-do-primitive-values-get-their-properties/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.