Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Ben Bacarisse Newsgroups: comp.lang.javascript Subject: Re: How would you prepare for javascripting interview? Date: Sun, 11 Sep 2016 01:32:04 +0100 Organization: A noiseless patient Spider Lines: 48 Message-ID: <87d1kbtgxn.fsf@bsb.me.uk> References: <50e38667-93da-4c5d-bc02-a78394f0ca3b@googlegroups.com> <1875389.irdbgypaU6@PointedEars.de> <9cstsb1uddjiltlflrdiks2ha2u3msi1ao@4ax.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: mx02.eternal-september.org; posting-host="017616aa25f81ec581c44d76d61ba2f3"; logging-data="16368"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+eu3Nij10Dw4kLqMu48jf+2nq2WTT3PzM=" Cancel-Lock: sha1:AOck6u2zL8s0Fz8yU3X3CeHUctc= sha1:tY7z2W3ff2vgWvWpTkmUL+MiSAU= X-BSB-Auth: 1.19d15c3f32f3c5dbe8b2.20160911013204BST.87d1kbtgxn.fsf@bsb.me.uk Xref: csiph.com comp.lang.javascript:31312 Doc O'Leary writes: > For your reference, records indicate that > Scott Sauyet wrote: > >> max([1, 2, 3]) // 3 >> == max(max([1]), max([2, 3])) // max(1, 3) == 3 >> == max(max([1, 2]), max([3])) // max(2, 3) == 3 >> != max(max([]), max([1, 2, 3])) // max(NaN, 3) == NaN >> >> Just by partitioning a set differently we can change its maximum. > > People need to stop making this mistaken argument. This has nothing > to do with the mathematical sets. It has to do with a function in a > library of computer code. That function in question is, quite reasonably, variadic and the above is just shorthand to simplify making the point. The max function shown is just var max = list => Math.max.apply(null, list) Being able to apply Math.max to a list is one reason it is variadic. Given that, you don't want the partitioning a list to affect the result; you want the maximum height of a class to be the larger of the maximum of the heights of the boys and that of the girls. >> I lean toward the latter >> partly because I've done a lot of mathematical programming over the years >> (yes, even in Javascript) so having useful mathematical functions is >> important to me > > And that’s a fine argument, and especially appropriate here because > we *are* talking about what is implemented by the Math object. But > I would still argue that JS is not well-considered when it comes to > other objects (the some/every methods of Array) or even other methods > in Math (pow has a right identity, but still requires 2 arguments). > The inconsistencies make things ugly. I'm sure there *are* some inconsistencies, but max and min are, in this regard, consistent with every and some and Math.pow is unavoidably different from them all. That's not an inconsistency in the design. -- Ben.