什么是js
JavaScript简称JS,是较为流行的一种前端编程语言,是一种脚本语言,通过解释器运行,主要在客户端(浏览器)上运行,也可以基于node.js在服务器端运行
- 前端所使用的编程语言
- 弱类型动态语言
使用js的三种方式
- 行内
<button onclick="alert('你点到我了')">点我</button>
- 内嵌
可以在任何地方引入
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>引入js</title>
<script>
console.log("hello world head里面")
</script>
</head>
<body>
<script>
console.log("hello world body里面")
</script>
</body>
<script>
console.log("hello world body外面")
</script>
</html>
<script>
console.log("hello world html的外面")
</script>
- 外部引入
<script src="index.js"></script>