🌟object -> primitive conversion
Last updated
Last updated
JS ⟩ value ⟩ type ⟩ conversion ⟩ object -> primitive
JS spec defines 3 algorithms for object -> primitive conversion:
prefer-string:preferring a string (if conversion is possible)
prefer-number:preferring a number (if conversion is possible)
no-preference:classes choose their own preference.
object -> number:
object -> string:
object -> primitive algorithms are involved in:
object -> primitive algorithms may result in TypeError