dublintech
dublintech

Reputation: 17795

Adding properties dynamically in javascript

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.

Upvotes: 1

Views: 248

Answers (2)

badunk
badunk

Reputation: 4350

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).

Upvotes: 0

biziclop
biziclop

Reputation: 14626

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.

Upvotes: 2

Related Questions