Files
ClassContent/历届学生/刘合群/2019-07-19/index.html
2024-09-27 02:06:13 +08:00

146 lines
3.2 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title> js 第一课 </title>
</head>
<body>
<script>
// 变量 在计算机内存中存储但是可被改变的数据
// 变量定义var 变量名称;
var ColorRed = "dddd";
// 变量定义后 可以对他进行 赋值
console.log(ColorRed)
// 变量起名字需要遵循一个规则:
// 不能以数字或者特殊符号开头(_ , $),一般以字母开头
// 变量命名区分大小写
// 一般变量名称需要具有含义(英文单词来命名)
// 最好遵循驼峰命名法
// 变量的类型
// stringnumberboolean(布尔, true false)NullUndefined
// ArrayObjectfunction
var name = "刘合群"
console.log(typeof name)
var price = 100
console.log(typeof price)
var a = true
console.log(typeof a)
// 一些具有相同特征或者作用的数据的集合
// 数组定义
// 1
// var classRom = new Array()
// classRom[0] = 121
// classRom[1] = 123
// classRom[2] = 124
// 2
// var classRom = new Array(121,123,124)
// 3
// var classRom = [121,123,124]
// var classRom = [
// [[129,130],[119,110]],
// [20,50,34]
// ]
// console.log(classRom)
// 对象是某个具体事物的特征或者作用的数据集合
// 定义1
// var car = new Object();
// car.color = "red"
// car.price = '20万'
// var car = new Object({
// color: "red",
// price: '20万'
// })
// var car = {
// color: 'red',
// price: '20万',
// start: function() {
// console.log("点火方法,可以启动车辆")
// }
// }
// console.log(car.price)
// function是某些为了完成同样功能的代码的集合
// 1 定义
function buyEat(money) {
return "我帮到你带了20块的炒饭"
}
// 2 使用
var result = buyEat(20)
console.log(result)
// 函数分为两种,有参数函数,无参函数
function resultss(a, b) {
return a + b
}
console.log( resultss(100,400) )
// 控制语句:控制程序运行流程的特殊代码
// if (if else), switchwhile(do while)for(for in, forEach, map)
// break, Continue
// if (2 == 3) {
// console.log("true")
// } else {
// console.log("false")
// }
// var names = 2
// switch (names) {
// case 1 :
// console.log(1)
// break;
// case 2 :
// console.log(2)
// break;
// default:
// console.log("错误")
// break;
// }
// for 可控制的去不断运行代码
// 求100以内所有数和
// var sum = 0;
// for(var i = 1; i <= 100; i++ ) {
// sum += i
// }
// console.log(sum)
// var j = 100
// while (j < 10) {
// console.log(j)
// j++
// }
// do {
// console.log(j)
// j++
// } while (j < 10);
// var list = [445,254,33,4354]
// for(var i = 0; i < list.length; i++) {
// console.log(list[i])
// }
</script>
</body>
</html>