左括号和右括号背后的含义是什么?
具有左括号和右括号的代码背后的意义是什么?
这是我正在查看的示例代码:
<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();
What's the meaning of using open and close broders ()
?
What is the point or meaning behind having code that has open and closes parentheses?
Here's the sample code that I'm looking at:
<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';
}
" />
The line I'm curious about is here:
this.select();
What's the meaning of using open and close brackets ()
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这些被称为圆括号,而不是“方括号”。它们将参数包含在函数调用中。函数
select
不接受任何参数,但您仍然需要在此处添加括号才能调用该函数。THose are called parentheses, not "brackets". They enclose the arguments to a function call. The function
select
doesn't take any arguments, but you still have to put the parentheses there to call the function.除了欧内斯特所说,它还有助于识别函数而不仅仅是变量。
如果您不熟悉代码,如果没有括号,您将不知道某个东西是函数还是变量。
Adding to what ernest said, it also helps to identify a function rather than just a variable.
Without the parentheses you would have no idea if something was a function or a variable if you were unfamiliar with the code.