# Trying to understand using numerals as variable names in objects. is it ok?

**URL:** https://forum.kirupa.com/t/trying-to-understand-using-numerals-as-variable-names-in-objects-is-it-ok/301213
**Category:** Uncategorized
**Created:** [December 5, 2009, 6:34am UTC](https://forum.kirupa.com/t/trying-to-understand-using-numerals-as-variable-names-in-objects-is-it-ok/301213 "2009-12-05T06:34:45Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Shaedo](https://avatars.discourse-cdn.com/v4/letter/s/e19b73/32.png) [@Shaedo](https://forum.kirupa.com/u/Shaedo)
#### Post date: [December 5, 2009, 6:34am UTC](https://forum.kirupa.com/t/trying-to-understand-using-numerals-as-variable-names-in-objects-is-it-ok/301213/1 "2009-12-05T06:34:45Z")

</div>

EDIT I just found that **Senocular** did much the same thing so I guess that means it’s ok…  
[http://www.senocular.com/flash/actionscript/?file=ActionScript\_3.0/com/senocular/utils/KeyObject.as](http://www.senocular.com/flash/actionscript/?file=ActionScript_3.0/com/senocular/utils/KeyObject.as)

I am curious about using numerals as variable names in objects.  
I am not sure how to explain this but the code below shows what I mean:

```auto
var o:Object=new Object();
o['123']=true;// so is kinda an equivalent to 'o.123' ??
trace(o['123']);//true
//trace(o.123);//1084: Syntax error: expecting rightparen before .123.
o['abc']=true;
trace(o.abc);//true //works fine of course
trace(o['abc']);//true

```

so as long as I put my reference in square brackets [] is there any drawback from using numerals as variable names?

The reason I was wondering about this is because I am using a global static object and then assigning keyCodes to it eg:

```auto
	private function KD(e:KeyboardEvent):void
	{
		Keys.KO[e.keyCode]=true;
	}

```

where Keys is my global class and KO is my object and I can just check say

```auto
if(Keys.KO['65']==true)trace('key a is down');

```

and yes I know I could always concat with a letter eg

```auto
Keys.KO['k'+e.keyCode]=true;

```

but I would still like to understand it all…

thank you for your consideration,  
S.
