MyWiki:Reference desk/Archives/Computing/2016 November 10
This template must be substituted. Replace {{Archive header with {{subst:Archive header.
|- ! colspan="3" align="center" | Computing desk |- ! width="20%" align="left" | < November 9 ! width="25%" align="center"|<< Oct | November | Dec >> ! width="20%" align="right" |Current desk > |}
| Welcome to the Wikipedia Computing Reference Desk Archives |
|---|
| The page you are currently viewing is a transcluded archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages. |
Contents
November 10
[edit source]Javascript: preventing anonymous variable member names from clashing with parent scope
[edit source]I'm just learning Javascript and having a little difficulty instantiating anonymous objects with variable names that shadow those of the parent scope. Suppose you had something like this:
function example(parameters)
{
return parameters.foo + parameters.bar;
}
function test
{
var foo = 67;
var bar = 163;
// ...do something with foo and bar here, and then...
var baz = example({ foo: this.foo, bar: this.bar }); // Error!
}
What's the right syntax to do that sort of thing? Earl of Arundel (talk) 04:30, 10 November 2016 (UTC)
- First of all, you're missing a pair of parentheses after
function test. Within thetestfunction,thisrefers to theWindowobject, not the function itself, sothis.fooandthis.barare bothundefined. If you just writevar baz = example({ foo: foo, bar: bar });then it should work as you expect. AndrewWTaylor (talk) 09:25, 10 November 2016 (UTC)- Right! Very simple. Well, thanks so much for the help. Earl of Arundel (talk) 14:28, 10 November 2016 (UTC)
Stable IPv6s
[edit source]Do they exist? My experience with IPv6s is only with dynamic ones, where the same person is assigned to various IPs in a range of trillions or quadrillions of addresses, but I don't have significant amounts of experience. Nyttend (talk) 18:22, 10 November 2016 (UTC)
- Yes... or at least they should. RFC4941 says
Devices implementing this specification MUST provide a way for the end user to explicitly enable or disable the use of temporary addresses
, which means that there should be an option to get a static address (if you are using a fixed address point; I do not think there is a way to keep the same IPv6 on a mobile terminal that moves around).
- Notice though that (1) Android violated (and maybe is still violating) that RfC; (2) the default configuration on most systems may still be dynamic addresses, and few change the default configuration. TigraanClick here to contact me 18:38, 10 November 2016 (UTC)