How are they different and why would you use one over the other?
For example:
function setupOptionsObj(num) {
return {
data: num,
func: function() {
return num * 10
}
}
}
function setupOptionsConstructor(num) {
this.data = num;
this.func = function() {
return num * 10
}
}
var one = setupOptionsObj(123)
var two = new setupOptionsConstructor(123)
console.log(one.func());
console.log(two.func());
Thank you :)