Jump to content

Wikipedia:Reference desk/Archives/Computing/2016 November 10

From Wikipedia, the free encyclopedia
Computing desk
< November 9 << Oct | November | Dec >> November 11 >
Welcome to the Wikipedia Computing Reference Desk Archives
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


November 10

[edit]

Javascript: preventing anonymous variable member names from clashing with parent scope

[edit]

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)[reply]

First of all, you're missing a pair of parentheses after function test. Within the test function, this refers to the Window object, not the function itself, so this.foo and this.bar are both undefined. If you just write var baz = example({ foo: foo, bar: bar }); then it should work as you expect. AndrewWTaylor (talk) 09:25, 10 November 2016 (UTC)[reply]
Right! Very simple. Well, thanks so much for the help. Earl of Arundel (talk) 14:28, 10 November 2016 (UTC)[reply]

Stable IPv6s

[edit]

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)[reply]

  • 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)[reply]