In javascript methods, I usually don't return anything if I don't need to. But then the question arose. How does javascript clear memory if I don't return anything? I know that JS uses the garbage collector .. so ... somehow it clears the memory for me. So my actual question is, what is considered to be BEST practice to return true or false even in situations where you are not expecting 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? }
source share