Skip to content

Comment on Google Closure: How not to write Javascriptparent

Comments

I've done a lot of testing on creating strings by concatenation and it turns out that + is actually one of the slowest. It's much faster, for example, to create an array and then join it with "". Maybe try that in your test and see how it compares.

Example:

  x = []
  x.push("latortuga")
  x.push(" is so right")
  str = x.join("")

That's a different issue than the what the OP was writing about, which is getting a string representation of an object, in this case, a function.

This used to be true in Python as well, but I'm not sure if it still holds for recent versions.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.