练习
This commit is contained in:
44
teaching/lhj/kejian/js/js基础.html
Normal file
44
teaching/lhj/kejian/js/js基础.html
Normal file
@@ -0,0 +1,44 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
<!-- <script src="./jichu.js"></script> -->
|
||||
<script>
|
||||
// alert("hello world")
|
||||
// js 引入方式:
|
||||
// 1. 内部引入 在html文件里面写script标签 在标签内写 js的代码
|
||||
// 2.外部引入 `<script type="text/javascript" src=""></s\cript>
|
||||
// 3.从html中执行js代码
|
||||
|
||||
var name=123
|
||||
// console.log(name)
|
||||
document.write(name)
|
||||
// 变量命名规则 不能数字开头 变量名包含 字母 数字 下划线 $ , 不能用关键字和保留字
|
||||
|
||||
// 数据类型:
|
||||
// 简单 undefined null number boolean string
|
||||
// 复杂数据类型 object =>array(数组)
|
||||
// =》 function(函数)
|
||||
|
||||
// 检测数据类型
|
||||
// typeof
|
||||
// instanceof
|
||||
// Object.prototype.toString.call()
|
||||
|
||||
console.log(typeof true) //Boolean
|
||||
console.log(typeof undefined) //undefined
|
||||
console.log(typeof "true") // String
|
||||
console.log(typeof 3.14)// Number
|
||||
console.log(typeof (2+"2"),999)// String(1) Number(2)
|
||||
console.log(typeof {})// Object
|
||||
console.log(Object.prototype.toString.call([]))// [object Array]
|
||||
console.log(typeof function(){},function(){} instanceof Object) // null ,false object,不定
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<button onclick="alert('hello')">sub</button>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user