In javascript methods, I usually don't return anything if I don't have to. But then a question poped up. How does javascript clears the memory if I don't return anything? I know that JS uses garbage collector..so..somehow it clears memory for me. So my actual question is, is it considered a BETTER practice to return true or false even in those situations you don't expect any return values such as the following?
// assuming we get birthday in mm/dd/year format
function setAge( birthDay )
{
var _birthdaySplited = birthDay.split("/");
this.age = new Date().getFullYear() - parseInt( _birthdaySplited[2] );
// should I say..return true here?
}
Is it considered a BETTER practice to return true or false even in those situations you don't expect any return values such as the following?
How does javascript clears the memory if I don't return anything?
Not explicitly returning a value has effectively zero impact on garbage collection. I'm not sure why you think it might.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With