繁体   English   中英

何时在括号中使用双引号/单引号?

[英]When to use double quotes/single quotes in parentheses?

什么时候在函数中使用和不使用单引号或双引号?

例如:

function convertToInteger(str) {
  return parseInt(str); // why do we not use double-quotes here? is this as simple as we never use quotes around arguments when calling a function?
}

convertToInteger("56");

function 中的变量称为 arguments。它们用于存储您传递的项目。 当你传递它时,它会使用你输入的任何值,但如果你将一个值放在引号中,你将设置一个固定值。

变量值应该在引号中,变量名不应该在引号中。

convertToInteger("56");

或者

变种数据值=“56”;

转换为整数(数据值);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM