How to set a default value for Javascript parameters

Asked

Viewed 28 times

0

Good afternoon!

I won’t go into a system context, not to stretch, but let’s assume the code below:

let meuNome = "Lucas"
function setNome(meuNome) {
    return meuNome;
}

As you can see, I want my variable to go straight into the parameter, only this way it won’t work for obvious reasons. How should I treat this case then?

Thank you!

EDIT

How to set a default value for Javascript parameters

  • 1

    What exactly do you want to do? You want to set a default value for the parameter?

  • That’s right, Anderson. In PHP I can, in JS I don’t know how it works.

  • Thanks! I will read, thank you so much for knowing "ask" for me rs.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.