A user account is required in order to edit this wiki, but we've had to disable public user registrations due to spam.

To request an account, ask an autoconfirmed user on Chat (such as one of these permanent autoconfirmed members).

IDL: Difference between revisions

From WHATWG Wiki
Jump to navigation Jump to search
(Created page with "== sequence vs [] == * When an method returns a sequence it always returns a new JavaScript Array. * When a method returns a [] it either returns a new copy or the same. ** T...")
 
Line 1: Line 1:
== sequence vs [] ==
== sequence ==
 
* As return value always returns a new JavaScript Array.
* Better than [] for methods and dictionaries taking arrays.
 
== [] ==


* When an method returns a sequence it always returns a new JavaScript Array.
* When a method returns a [] it either returns a new copy or the same.
* When a method returns a [] it either returns a new copy or the same.
** The returned object is not a JavaScript Array.
** The returned object is not a JavaScript Array.

Revision as of 19:10, 10 July 2013

sequence

  • As return value always returns a new JavaScript Array.
  • Better than [] for methods and dictionaries taking arrays.

[]

  • When a method returns a [] it either returns a new copy or the same.
    • The returned object is not a JavaScript Array.
    • If the returned object is declared readonly it can still be manipulated by the browser, unlike a frozen JavaScript Array.
    • In general this is probably better avoided. There's a desire expressed to kill [].