1

In Javascript you add properties to an object dynamically for example:

var car = {colour: "blue"};
car.reg = "XYXABC00D";

Is there a special buzzword for this?

Thanks.

dublintech
  • 16,815
  • 29
  • 84
  • 115

2 Answers2

2

Your buzzword might be called the expando.

Well, in javascript, any object is an expando object. What it means is, as the article covers, that whenever you try to access a property it will automatically be created.

In practice the name "expando" is only used when a dynamic property added to a DOM node, which made "funny" things in ancient Internet Explorer versions.

Community
  • 1
  • 1
biziclop
  • 14,466
  • 3
  • 49
  • 65
  • I'm not sure what you mean by "In practice it is only used when a dynamic property is added to a DOM node". I dynamically add keys to objects quite frequently... – Peter Olson Mar 16 '12 at 21:46
  • Sorry, I meant that the expression "expando" is generally used in DOM context, especially when IE memory leaks are discussed. – biziclop Mar 16 '12 at 21:49
  • What's the word to cover the programming technique when there is no DOM? – dublintech Mar 16 '12 at 21:50
  • What's wrong with "I added a `date` property to object `o`"? :) – biziclop Mar 16 '12 at 21:54
0

Since objects in javascript are associative arrays, adding a dynamic property is simply mapping a key/value pair. So perhaps the technical term you're looking for is probably related to assigning/mapping (terms that are related to associative arrays instead of the dynamic object).

badunk
  • 4,310
  • 5
  • 27
  • 47