开括号和闭括号的含义是什么?

What's the meaning behind open and closed parentheses?

本文关键字:是什么      更新时间:2023-09-26

有开括号和闭括号的代码背后的意义是什么?

下面是我正在看的示例代码:

<input style="background-color:#bfdfff" name="fn" type="text" id="kfn" 
    size="55" maxlength="55" onfocus=                   
        "this.select(); 
        if (this.value==''){
          this.style.background='#00CCCC';
        }
        else
        {
          this.style.background='#99CCFF';
        }
" />

我感兴趣的行在这里:

this.select(); 

使用左右括号()是什么意思?

这些被称为圆括号,而不是"括号"。它们包含函数调用的参数。函数select不接受任何参数,但是您仍然需要在那里放置圆括号来调用该函数。

除了ernest所说的,它还有助于识别一个函数而不仅仅是一个变量。如果不熟悉代码,如果没有括号,就不知道是函数还是变量。