<!-- 运算符 -->
var a1 = 5;
var a2 = 4;
console.log(a1%a2);//求模 结果为:1
if(a1>a2){
alert('a1>a2');
} else{
alert('a1<a2');
}
//在js中字符串拼接用“+”
console.log(3+'word'+5+'hello'); //3word5hello
console.log(3+5+'hello'+1+'world'); //8hello1world
console.log(3+5+'hello'+2+2+'world'); //8hello22world
//控制结构
//var name=new Array("zhao","qian","sun","li");
var name = ['zhao' , 'qian' , 'sun' , 'li'];
//console.log('name is length:'+name.length);
for(var i = 0 ; i < name.length ; i ++){
console.log(name[i]);
}
JavaScript基础入门(运算符、js中的字符串拼接、控制结构)
最新推荐文章于 2024-03-29 08:48:44 发布