Skip to content

Different behaviour on custom type with String() method #619

Answered by dop251
pgundlach asked this question in Q&A
Discussion options

You must be logged in to vote

This one is a bit tricky... Properties in ECMAScript can only be strings or Symbols, so the key must be converted into string before used as a property name, and if a value is a fmt.Stringer then the String() method is used for that.

If you can change the javascript code, you can work around that by doing d.Items[Number(key)] = "bar".

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@pgundlach
Comment options

Answer selected by pgundlach
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants