JavaScript: test vs exec
I would like to know what's the best way to check a string for example (mail, password ..Etc).

    /^...$/i.exec(a)

vs

    /^...$/i.test(a)

- **exec** returns value
- **test** true

**test:**

    // 1° way
    var mail = req.body.mail;
    if(check(mail)){

**exec:**

    // 1° way
    var mail = req.body.mail;
    if(check(mail)){

    // 2° way
    var mail = check(req.body.mail);
    if(mail){


**exec** or **test** ? and what number ( 1° or 2° if exec)

I would like to know if you know some ways to use them differently.

Thanks !


**EDIT**

I think that test is best for this use. (more logical and certainly faster)
JavaScript: test vs exec
===

I would like to know what's the best way to check a string for example (mail, password ..Etc).

    /^...$/i.exec(a)

vs

    /^...$/i.test(a)

- **exec** returns value
- **test** true

**test:**

    // 1° way
    var mail = req.body.mail;
    if(check(mail)){

**exec:**

    // 1° way
    var mail = req.body.mail;
    if(check(mail)){

    // 2° way
    var mail = check(req.body.mail);
    if(mail){


**exec** or **test** ? and what number ( 1° or 2° if exec)

I would like to know if you know some ways to use them differently.

Thanks !


**EDIT**

I think that test is best for this use. (more logical and certainly faster)