Files
2024-09-27 02:06:13 +08:00

84 lines
1.7 KiB
HTML
Raw Permalink 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>
</body>
<script>
// 定义了一个变量,变量的名字叫 name
// var a = 1000;
// var b = 1
// console.log(a); // 1000
// a = 99
// console.log(a); // 99
var a = 1;
var b = "1";
// + 有两个功能
// + 左右两边的数据类型必须都是number那么进行数学运算
// + 左右两边只要有一个不是number那么进行 字符串 拼接
// - 会将左右两边的数据强制转换成 number然后进行减法运算
// console.log(b - a);
// * \
// console.log(a / b);
// console.log(a % b);
// ++ 让一个变量 自增 1
// ++a 首先让变量自增1然后把自增后的a带入程序中运算
// a++ 首先把变量的数值带入程序运算然后等程序运算完成后变量再自增1
// -- 让一个变量 自减 1
// console.log(a++)
// console.log(a++)
// console.log(a)
// a+=b --> a = a + b
// console.log(a+=b); // *= -= /= %=
// += 一般用来实现字符串的累加
// = 赋值
// == 等于 只会去检查两个数值是否一样
// === 全(绝对)等于
// 同时会去检查两个数值是否一样,并且去检查两个数值的数据类型是否完全一样,
// 当两个满足才返回true否则false
// var a = 1;
// var b = "1";
// console.log( (a == b) + a );
// console.log( ++( (++a) === b) + --(a == b) );
</script>
</html>