有人可以解釋何時在函式中使用和不使用單引號或雙引號嗎?
例如:
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");
uj5u.com熱心網友回復:
函式內部的變數稱為引數。它們用于存盤您傳遞的物品。當您傳遞它時,它將使用您輸入的任何值,但如果您將值放在引號中,您將設定一個固定值。
uj5u.com熱心網友回復:
變數值應該用引號引起來,變數名不能用引號引起來。
轉換為整數(“56”);
要么
var datavalue="56";
轉換為整數(資料值);
uj5u.com熱心網友回復:
function log(x) { // we create a function that accepts one parameter called x
console.log(x) // then we do something with the parameter we pass
}
// here we're calling the log() function
// and passing the string 'Hello, World!' to the function
// which accepts one parameter
log('Hello, World!')
參考(函式 - Javascript)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/446727.html
標籤:javascript 功能 论据
下一篇:還有其他選擇嗎?
