# Javascript: return?

**URL:** <https://forum.kirupa.com/t/javascript-return/29602>\
**Category:** Uncategorized\
**Created:** [August 28, 2003, 3:49pm UTC](https://forum.kirupa.com/t/javascript-return/29602 "2003-08-28T15:49:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![blah\_de\_blah](https://avatars.discourse-cdn.com/v4/letter/b/a8b319/32.png) [@blah\_de\_blah](https://forum.kirupa.com/u/blah_de_blah)\
**Post date:** [August 28, 2003, 3:49pm UTC](https://forum.kirupa.com/t/javascript-return/29602/1 "2003-08-28T15:49:21Z")

</div>

ok third thread today…not doin too good with javascript :-\

So i was just wondering…why do you need to do return true or return false??

And sometimes its just:

return true

and other times its:

return (true)

is there a difference? Not too sure what the return thing is used for :-\ Never used it anything similiar in flash either :-\ Any help would be great thanks!!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 28, 2003, 7:46pm UTC](https://forum.kirupa.com/t/javascript-return/29602/2 "2003-08-28T19:46:46Z")

</div>

you return true or false in order to do something. When you are validating a form you want to return true so the form gets processed or false so that the form doesn’t go thru if there is a problem…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 29, 2003, 4:54am UTC](https://forum.kirupa.com/t/javascript-return/29602/3 "2003-08-29T04:54:32Z")

</div>

Ah ok…since you’re here i won’t bother making a new thread 😛 Do you think you could explain this code from a email validation for me?

```php

function isEmailAddr(email)
{
  var result = false
  var theStr = new String(email)
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}

```

I just don’t understand:

if (index \> 0)  
{  
var pindex = theStr.indexOf(".",index);  
if ((pindex \> index+1) && (theStr.length \> pindex+1))  
result = true;  
}

that part (which is basically nearly the whole code :P). It is confusin me:-\ thanks
