loading...

re: Refactoring: My 6 favorite patterns VIEW POST

FULL DISCUSSION
 

very nice patterns, but I think on the number 6 you wanted to put it this way:

const myObject = { toName, punctuation, fromName };

// Before

function sayHello(myObject) {
  return `Hello, ${myObject.toName}${myObject.punctuation} From, ${myObject.fromName}.`
} 

sayHello(customerName, end, myName);

// After

function sayHello({ toName, punctuation, fromName }) {
  return `Hello, ${toName}${punctuation} From, ${fromName}.`
} 

sayHello(myObject);
code of conduct - report abuse