POV-Ray : Newsgroups : povray.beta-test : I have a hunch some of you may like this... : Re: I have a hunch some of you may like this... Server Time
29 Apr 2024 15:19:04 EDT (-0400)
  Re: I have a hunch some of you may like this...  
From: Mike Horvath
Date: 5 Oct 2016 04:41:24
Message: <57f4bcb4$1@news.povray.org>
On 10/5/2016 4:37 AM, Mike Horvath wrote:
>> I don't understand what you're saying. But Lua (sort of) does it like
>> this:
>>
>> method 1
>>
>>     #declare MyFrobnitz = dictionary {
>>       Foo = 42,
>>       Bar = "FTW!"
>>     }
>>
>> method 2
>>
>>     #declare MyFrobnitz = dictionary {
>>       ["Foo"] = 42,
>>       ["Bar"] = "FTW!"
>>     }
>>
>> method 3
>>
>>     #declare Key1 = "Foo";
>>     #declare Key2 = "Bar";
>>     #declare MyFrobnitz = dictionary {
>>       [Key1] = 42,
>>       [Key2] = "FTW!"
>>     }
>>
>
> I'm trying to find out if JavaScript does something similar to method 3,
> but I don't think it can.
>
> http://www.w3schools.com/js/js_objects.asp
>
> Mike


I take that back. It can and does.

	var textIdentifier = "blah"
	var tableObject =
	{
		[textIdentifier]: "wee"
	}
	alert(tableObject[textIdentifier])

Mike


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.