The JavaScript function parameter is assigned to the incoming method with the parameter name

  • 2020-05-17 04:46:29
  • OfStack

The example in this article shows how the parameters of the JavaScript function are passed in using a parameter name. Share with you for your reference. The specific analysis is as follows:

The idea here is that when you pass a parameter to a function, you can pass it with the parameter name: the parameter value, so you don't pass it wrong. However, the following code is implemented through a dictionary, unlike python, which supports this method intact


function foo({ name:name, project:project}) {
  Print( project );
  Print( name );
}

A method is called


foo({ name:'soubok', project:'jslibs' })
foo({ project:'jslibs', name:'soubok'})

I hope this article has helped you with your javascript programming.


Related articles: