Home  >  Article  >  Web Front-end  >  JavaScript function parameters use the method with parameter name to assign the incoming method_javascript skills

JavaScript function parameters use the method with parameter name to assign the incoming method_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:08:211935browse

The example in this article describes the method of assigning and passing in JavaScript function parameters with parameter names. Share it with everyone for your reference. The specific analysis is as follows:

Here is actually when passing parameters to a function, you can use parameter name: parameter value to pass, so that you will not pass the error. However, the following code is implemented through a dictionary, unlike python which supports such a method

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

Call method

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

I hope this article will be helpful to everyone’s JavaScript programming design.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn