Ⓜ️.valueOf()
🚧 under construction
JS ⟩ value ⟩ type ⟩ conversion ⟩ .valueOf()
in order for valueOf to be useful during type conversion, it must return a primitive.
all primitive types have their own custom valueOf methods.
⚖️ valueOf vs. toString
valueOf is called in priority by numeric conversion and primitive conversion.
string conversion calls toString() in priority.
.toString() - object -> string
Object.prototype.toString() - object -> string.
Object.prototype.valueOf() - object -> (primitive) value, if possible.
Last updated