Return statements at the end of a JavaScript function
javascript
Solution
The thing that may have gotten some people into the habit was event handlers for forms, if you have, say:
<form onsubmit="return myfunction();">
and `myfunction()` returns true, the form submits, else if it returns false it doesn't. People doing it in general could've got the habit from this. Some languages require return values from functions, Javascript doesn't; and having `return true` at the end of most functions serves no purpose.
Problem
I have seen in many times in JavaScript code people add a `return true` at the end although not necessary. Does anyone know why? ``` var _globalString; function doSomething() { _globalString= _globalString +' do something'; //some codes to do something more //finally adding a return true return true; } ```