DCL

An elegant OOP with mixins + AOP for JavaScript.

dcl.mix()

This is a utility function that does a shallow copy of properties from one object to another. It is used inside dcl and exposed because it is frequently required by user’s code.

Description

It copies properties from one object to another. The copy is shallow and does not involve cloning of objects.

The best way to describe dcl.mix() is to give its definition:

dcl.mix()
1
2
3
4
5
dcl.mix = function(a, b){
  for(var n in b){
    a[n] = b[n];
  }
};

Examples

Mix-in constants
1
dcl.mix(x, {a: 1, b: 2, c: "hello!"});

Notes

Even for totally empty objects IE6 lists some internal methods. Usually copying of these methods does no harm to objects.

Fork me on GitHub