Then you code snippet will run and return the value on the browser.
I use this to call getCenter() when using google map to figure out where I am now.
If you are doing business logic website, there are many times you want to confirm if a user wants to delete something.
return confirm("are you sure?");
ASP.NET provide a better approach and I discover it just recently.
In your code-behind
Page.ClientScript.RegisterStartUpScript(this.GetType(), "functionName", "TheScript", true);
This function will put your script at the end of that page and run after the page is completely loaded.