字符串需要加上""引號印衔,定義了的變量名不用""引號
彈出提示框
confirm("是你自己不努力状飞,說什么懷才不遇!")
彈出輸入框
prompt("你叫什么", "小白") 第二個參數(shù)小白是可選的捅僵,填了就成為輸入框里的默認(rèn)值,可以修改
if條件語句
當(dāng)()里的條件為真時拧揽,console.log()打印里面的內(nèi)容。
if( 7 > 4 ) {
console.log("you are right");
}
// you are right
if...else語句
if (7 > 8) {
console.log("出門左拐");
} else {
console.log("出門右拐");
}
//因為()里的條件返回false,所以執(zhí)行第二條console.log()狮惜,打印出門右拐
余數(shù)運算符%
console.log(9 % 5)
// 4
substring
"hello".substring(0, 2);
// he
0 1 2 3 4
| | | | |
h e l l o
字符串的下標(biāo)從0開始,substring()方法返回的子串包括start處的字符但是不包括stop處的字符
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者