devo-ps / devo-ps.github.io

devo.ps website
0 stars 2 forks source link

Code Reuse With Node.js #21

Closed fraserxu closed 11 years ago

fraserxu commented 11 years ago

The first example: The "Function copy"

var objectA = {
    lorem: 'lorem ipsum'
};
var objectB = {};

// Direct copy of a string, but you get the idea
objectB.lorem = objectA.lorem;
console.log(objectB); // Will output: { lorem: 'lorem ipsum' }

I usually do this:

Object.keys(a).forEach(function(key) {
    b[key] = a[key];
})

Done!

About Object.defineProperties()

The __defineGetter__ method seems to have been deprecated. But I don't know why many people are still using it. See here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineGetter

And also I suggest to put some related post on it. Like:

hunvreus commented 11 years ago

@makara ? Want to weight in that discussion. This goes live tonight 8:00 PM on Hacker News + Reddit + Google+...

makara commented 11 years ago

Thanks.

hunvreus commented 11 years ago

The next time send a Pull Request (really).

hunvreus commented 11 years ago

Any other link you would give as a resource @makara ?

makara commented 11 years ago

Made a small change https://github.com/devo-ps/devo.ps/commit/084900dd535116bf26b4dcaeb10ec07c3bb2f92e

No more additions.

hunvreus commented 11 years ago

Published. Didn't work well: I think mostly because of the title and the posting day (Thursday instead of Wednesday).