Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
hack64146yvar reason = getReason(1);
console.log(reason); // > undefined
If you prefix your function name with 'get', make sure it returns something. -
@nitwhiz it depends on the language, the system it is running on and how often it is called.
-
@Codex404 really? I actually made a jsperf for it, that's where I took the 2 percent from.:D
But I guess array access (mov) is always faster than jmp, sub, mov, ret.^^ -
@nitwhiz array access is quicker indeed, but if the array has to be initialized every single time that also cost time.
-
@Codex404 of course, yeah. But I guess it's common sense to put the array outside of this function.^^
-
-
@Codex404 but you'd use that memory once, you don't need to allocate and garbage collect it again and again and again.
Fragmented memory and slow performance vs upfront memory cost and high performance.
Related Rants
-
Deepett3My company seems to never have the money to do something right but always have the money to do it twice.
-
devTea21. Socializing with lots of people is tiring (if it’s a few then it’s okay) 2. I want to build something u...
-
Dizzy3You want the truth...? I just love being part of the dev memes :P Thats it!
;)
function getReason(num) {
switch (num) {
case 1:
console.log("Love to create something new!");
break;
case 2:
console.log("It's fucking cool!");
break;
case 3:
console.log("Money!");
break;
default:
console.log("Fuck offffff");
break;
}
}
rant
wk162