Home > Web Front-end > JS Tutorial > body text

JS custom function with default value_javascript skills

WBOY
Release: 2016-05-16 18:04:43
Original
945 people have browsed it

I started to take it for granted that it might be like
js code in languages ​​​​such as php or python.

function test(a,b="er"){ alert(a b ); } However, after the definition, it keeps reporting an error: missing object .After inquiry, I found that it cannot be defined like this in JavaScript. You can take advantage of the fact that arguments is a real parameter group. Please refer to the following example: js code



Copy code

The code is as follows:



After testing, it worked. It seems that everything has its own rules and cannot be taken for granted. Write it down here so you don’t make the mistake again later.
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template