Choice of function type in javascript

Asked

Viewed 21 times

2

I am starting in java script, however, not being able to understand the main difference between the use of these two functions, I know it can be a basic question but I do not understand, in which scenario I can apply one or the other.

function modificarNome(){
}

  var modificraNome = function(){

}
  • sure sorry.. But I wanted a more formal response.

  • 1

    There is no difference between the two in operation, but the second model you can use it to insert a function within an object, for example var objeto = { modificarNome: function(){...} } to use: objeto.modificarNome(). It can be on any level of the object: var objeto = { funcoes: { modificarNome: function(){...} } } to use: objeto.funcoes.modificarNome().

No answers

Browser other questions tagged

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