1.先来个helloworld
alert.('hello world');
完整的:两种方法,一种通过html调用js文件实现,另一种直接在html中写
<!doctype html>
<html lang="zh-hans">
<head>
<meta charset="UTF-8">
<!表示在浏览器标签显示的名字>
<title>JavaScript</title>
</head>
<body>
<script>
alert('hello one');
</script>
<script
src="java.js"></script>
</body>
</html>
2.关于log输出,类比Android log。e;ios中NSLog.
//2
var word="I'm a log";
var name="赵日天";
console.log(word);
console.log(name,"=============");
console.log(name,name+word);
console.log(name+word,name);
console.log(name+word);
3.type of方法,判断数据类型,可以返回6种类型:Object。number。string。undefined。sysmbol.function
if(typeof(name)=="string"){
console.log("是字符串");
}else{
console.log("不是字符串");
}