What was said in this sentence?

# Maxim Vaarwel (6 years ago)

"Whether the toString function can be applied successfully to a host object is implementation-dependent".

What does this sentence say? What kind of implementation are we talking about (The algorithm toString is concrete described)?

# T.J. Crowder (6 years ago)

On Wed, Feb 14, 2018 at 5:15 AM, Maxim Vaarwel <paloshmax at gmail.com> wrote:

"Whether the toString function can be applied successfully to a host object is implementation-dependent". What "implementation-dependent"

What does this sentence say? What kind of implementation are we talking about (The algorithm toString is concrete described)?

The most recent spec I can find with that sentence is the 5th edition, which is 3-4 editions out of date. I suggest using the latest draft standard as your primary reference.

To answer your question: The implementation in question is the implementation of the host object, not toString. In the 5th edition, "host object" is defined as:

object supplied by the host environment to complete the execution

environment of ECMAScript

For instance, a DOM object in a browser. ECMAScript cannot say that applying Array.prototype.toString or Object.prototype.toString to a host object will necessarily work as described (for instance, Object.prototype.toString.call(domElement)); it depends on the implementation of the host object.

-- T.J. Crowder

# Maxim Vaarwel (6 years ago)

Wow, thank you, I'm grateful to your answer. Thank you for helping me.