# Defining an object with variable properties

**URL:** <https://forum.kirupa.com/t/defining-an-object-with-variable-properties/94708>\
**Category:** Uncategorized\
**Created:** [November 15, 2003, 9:25pm UTC](https://forum.kirupa.com/t/defining-an-object-with-variable-properties/94708 "2003-11-15T21:25:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Voetsjoeba](https://avatars.discourse-cdn.com/v4/letter/v/ac91a4/32.png) [@Voetsjoeba](https://forum.kirupa.com/u/Voetsjoeba)\
**Post date:** [November 15, 2003, 9:25pm UTC](https://forum.kirupa.com/t/defining-an-object-with-variable-properties/94708/1 "2003-11-15T21:25:23Z")

</div>

Hello everybody 🙂

I’m facing a problem with defining objects. What I need to accomplish is this:

```auto

var cnms = this.cNames.split("|");
myDP = new Array({cnms[0]:"Chris", cnms[1]:"Priceless"}, {cnms[0]:"Nigel", cnms[1]:"Cheap"});

```

Obviously, this doesn’t work, otherwise I wouldn’t be typing this right now. How do I define an object with variable properties ? I’ve tried eval(), but it doesn’t work either.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 16, 2003, 2:11pm UTC](https://forum.kirupa.com/t/defining-an-object-with-variable-properties/94708/2 "2003-11-16T14:11:55Z")

</div>

Huh ? What are you doing there ? 😛
