функция расширения объекта (JavaScript)

function $_extend(o, a, y) {
    for (y in a) o[y] = a[y];
    return o
}
 
var obj1 = {a: 1, b: 2, c: 3};
var obj2 = {x: 'a', y: 'b', z: 'c'};
var new_obj = $_extend(obj1, obj2);
console.log(new_obj); // {a: 1, b: 2, c: 3, x: 'a', y: 'b', z: 'c'}

дядь Саша

hardcore javascript & php programmer, passionate reverse engineer

You may also like...

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.