Joined November 2012
·
Posted to
JavaScript Constructors
over 1 year
ago
Nice. I've grown fond of doing this:
var Order = (function() {
// initialise some stuff before the return
return function Order(x){
this.id = x;
}
})();
var order = new Order(1);
Achievements
49 Karma
0 Total ProTip Views
Raven
Have at least one original repo where some form of shell script is the dominant language
Walrus
The walrus is no stranger to variety. Use at least 4 different languages throughout all your repos
Python
Would you expect anything less? Have at least one original repo where Python is the dominant language
Mongoose 3
Have at least three original repos where Ruby is the dominant language
Mongoose
Have at least one original repo where Ruby is the dominant language
That is because at the time constructor is invoked with
new
,stranger
is 2. Only afterorder.value
is assigned doesstranger
become 3.The self executing function may be overkill but maybe it's because I'm new to all of this that I'm finding the amusement in it: