W3C home > Mailing lists > Public > public-script-coord@w3.org > October to December 2013

[Bug 23532] Dealing with undefined

From: <bugzilla@jessica.w3.org>
Date: Wed, 23 Oct 2013 15:08:53 +0000
To: public-script-coord@w3.org
Message-ID: <bug-23532-3890-Z9QYSAy2fn@http.www.w3.org/Bugs/Public/>
https://www.w3.org/Bugs/Public/show_bug.cgi?id=23532

--- Comment #15 from Domenic Denicola <domenic@domenicdenicola.com> ---
>  since I suspect web developers would prefer a clear indication that a call like document.body.setAttribute() (with no arguments) is incorrect instead of it silently doing something bogus...

I don't think this is true, given the wide acceptance and prevalence of web
developer-created libraries that do not do argument validation of this sort.
(For example, jQuery.) Argument validation exceptions are not idiomatic to or
expected by JavaScript code, generally. The only general case where I can
recall developers writing them is for ensuring that properties of a
configuration file necessary for app startup are present.

That said, even though I think it is a mistake to have these kind of argument
validation exceptions, I can see that there are a number of people writing
standards who are fond of them, so in the end it's unlikely that developers'
desires are really what's going to decide the outcome here. With that in mind I
think the original post describes the best way to express required arguments:
if it's `undefined`, throw your `TypeError`.

Finally, I'd like to emphasize that `arguments`, and thus `arguments.length`,
won't even be available inside any of ES6's new function forms, e.g. arrow
functions, or any functions that use default arguments, rest parameters, or
destructuring in their declaration. TC39 is trying as hard as possible to kill
`arguments`.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
Received on Wednesday, 23 October 2013 15:08:55 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:18 UTC