Skip to content

Commit 4f58e8d

Browse files
committed
Date
1 parent e06f45f commit 4f58e8d

8 files changed

Lines changed: 574 additions & 0 deletions
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Title</title>
6+
</head>
7+
<body>
8+
9+
<script>
10+
console.log(typeof "hello");//console.log()控制台输出内容
11+
console.log(typeof 222);//"number"
12+
console.log(typeof '222');//"string"
13+
console.log(typeof false);
14+
console.log(typeof "false");//这个上面的都是基本数据类型/
15+
console.log(typeof null);//object//object function 是引用数据类型;
16+
console.log(typeof {});
17+
console.log(typeof function () {});//function
18+
19+
//变量是数据的代言人;
20+
var demoStr="hello";
21+
console.log("-----------------------");
22+
console.log(typeof demoStr);//string
23+
demoStr=22;//不推荐这么做 ;
24+
console.log(typeof demoStr);//number
25+
26+
//typeof 总是返回string类型的; typeof()
27+
console.time("123");
28+
console.log("+++++++++++++++++++++");
29+
console.log(typeof (typeof "hello"));
30+
console.log(typeof (typeof 222));
31+
console.log(typeof typeof '222');
32+
console.log(typeof typeof false);
33+
console.log(typeof typeof "false");
34+
console.log(typeof typeof null);
35+
console.log(typeof typeof {});
36+
console.log(typeof typeof function () {});
37+
console.timeEnd("123");
38+
39+
console.assert(1==1,"打脸了");
40+
41+
var aloneVal=Symbol();
42+
console.log(typeof aloneVal);//symbol 存在的意义,避免多人开发时,变量覆盖;
43+
44+
</script>
45+
</body>
46+
</html>
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Boolean</title>
6+
</head>
7+
<body>
8+
<script>
9+
var a=52;
10+
var b=30;
11+
12+
function demoBoolean(a, b) {
13+
if (a>b){//2>30 -> false
14+
console.log(a+" 大于 " +b)
15+
}else if(a==b){//2==30 -> false
16+
console.log(a+" 等于 " +b)
17+
}else{
18+
console.log(a+" 小于 " +b)
19+
}
20+
console.log(a>b);
21+
console.log(a==b);
22+
23+
24+
if(null){
25+
console.warn("条件为真的时候才输出")
26+
}else{
27+
console.warn("if条件为假的时候才输出")
28+
}
29+
}
30+
31+
demoBoolean(a,b);
32+
/*
33+
* 如果a>B; ->"a的值"大于"b的值"
34+
* 如果a==B;->"a的值"等于"b的值"
35+
* 如果a<B;->"a的值"小于"b的值"
36+
*
37+
* */
38+
39+
40+
/* ................................非常重要。。。。。。。。。。
41+
* 哪些值是false(false本身)
42+
* 数字:0、-0 、NaN、
43+
* 字符串:''(空字符串)
44+
* null 、
45+
* undefined、
46+
* */
47+
48+
console.log("---------------------------------");
49+
console.log(Boolean(0)); //false
50+
console.log(Boolean(-0)); //false
51+
console.log(Boolean(1)); //true
52+
console.log(Boolean(-5)); //true
53+
console.log(Boolean("222"));//true
54+
console.log(Boolean('')); //false 空的字符串
55+
console.log(Boolean(" ")); //true 包含空格的字符串
56+
console.log("---------------------------------");
57+
console.log(Boolean("0"));//true
58+
console.log(Boolean(null));//false
59+
console.log(Boolean(undefined));//false
60+
console.log(Boolean({}));//true
61+
console.log(Boolean(function () {}));//true
62+
console.log(Boolean(false));//false
63+
console.log("---------------------------------");
64+
console.log(Boolean(55*"asd"));// NaN false
65+
66+
67+
// ! !!
68+
console.log("************************");
69+
console.log(Boolean(0));//false
70+
console.log(Boolean(!0));//true
71+
console.log(!0);//true 原理: 0 隐式的调用Boolean方法Boolean(0) -> false -> !false ->true
72+
console.log(!!0);// !(!false)->!true ->false
73+
74+
</script>
75+
</body>
76+
</html>
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Number</title>
6+
</head>
7+
<body>
8+
<script>
9+
//正数,负数,零,NaN都是属于Number
10+
// ***NaN -> Not a Number不是一个数,但是属于数字类型;**
11+
console.log(typeof 222);
12+
console.log(typeof 222.22);
13+
console.log(typeof -10);
14+
console.log(typeof -10.34);
15+
console.log(typeof 0);
16+
console.log(typeof -0);
17+
18+
//NaN
19+
console.log((22*"aa"));//NaN number
20+
console.log(typeof (22*"aa"));//number
21+
console.log(22==22);//true 单个等于号是赋值的意思; Invalid left-hand side in assignment
22+
//== 两个等于号才是判断;
23+
console.log((22*"aa")==(22*"bb"));//false
24+
console.log((22*"aa")==22);//false
25+
26+
//inNaN
27+
console.log(isNaN(22*"aa"));//true (22*"aa")计算出的值不是一个数,对吗? 对;
28+
console.log(isNaN(22));// 22这个值不是一个数,对吗? 不对; false (NaN -> Not a Number不是一个数,)
29+
30+
//number的转换方法; 别的数据类型转为数字类型;(不一定是字符串)
31+
/* 五种 转为数字的;
32+
* +"22" 字符串转为数字;
33+
* "22"-0
34+
* Number()
35+
* parseInt()
36+
* parseFloat()
37+
* */
38+
console.log("+++++++++++++++++++++++++");//隐式
39+
console.log(+"22");//隐式
40+
console.log(Number("22"));//显式 22
41+
console.log(Number(false));//显式 ->0
42+
console.log(Number(true));//显式 ->1
43+
console.log(Number(null));//显式 -> 0
44+
console.log(Number(undefined));//显式 NaN
45+
console.log(Number({}));//显式
46+
console.log(Number("22.22"));
47+
console.log(Number("22.22a"));//失败了 NaN
48+
49+
50+
console.log(parseInt("22.22a"));//22
51+
console.log(parseFloat("22.22a222"));//22.22
52+
console.log(parseFloat("22.22.22"));//22.22
53+
54+
// + - * /
55+
56+
console.log(("++++++++"));
57+
console.log(13%10); //13/10 3 多余的3 会被输出
58+
console.log(5%3);//2
59+
60+
var time=623648364569346563463;//time单位是秒;转为X分X秒;
61+
var minis=parseInt(time/60);//保存是分钟
62+
var second=time%60;//3
63+
var targetVal=minis+"分"+second+"秒";
64+
65+
console.log(" minis:"+minis+" second:"+second);
66+
console.log(targetVal);
67+
//小练习:
68+
/*
69+
* var time=623648364569346563463;//time是怎么得到的》当前的服务器时间 - 双11 这个阶段多少秒;
70+
* 是多少天,多少小时,多少分钟,多少秒;
71+
* */
72+
73+
74+
console.log("***********************");
75+
console.log("22"-1);//"22" -> 22 -> (22-1) -> 21
76+
console.log("22"-0);
77+
78+
</script>
79+
</body>
80+
</html>
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Title</title>
6+
</head>
7+
<body>
8+
<script>
9+
var num=2;
10+
console.dir(num);//number 实例
11+
console.dir(num.__proto__);//Number 类
12+
/*
13+
*
14+
* constructor :Object
15+
*
16+
*
17+
* */
18+
19+
var str="haha";
20+
console.dir(str);//string 实例
21+
console.dir(str.__proto__);//String 类
22+
23+
24+
/*判断是否一致*/
25+
console.log(num.__proto__.__proto__=== str.__proto__.__proto__);//true
26+
27+
28+
//万物皆对象,并不等于只有一个对象类型的;
29+
// Number / String / Object / Boolean
30+
31+
32+
//key:value
33+
//1、字面量的创建方式;推荐的方式
34+
var o={
35+
name:"zhu",
36+
say:"hello"
37+
};
38+
console.log(o);//{name: "zhu", say: "hello"}
39+
40+
var oDemo={};
41+
// oDemo.name1=
42+
if(!oDemo.flagVal){
43+
oDemo.flagVal="Test"
44+
}
45+
oDemo.name="bang";
46+
oDemo.say="hahahahahahahha";
47+
console.log(oDemo.flagVal);//Test
48+
console.log(oDemo);//{flagVal: "Test", name: "bang", say: "hahahahahahahha"}
49+
50+
//new
51+
var demo1=new Object();//不推荐的使用方法;
52+
demo1.haha="hahahahahahah";
53+
console.log(demo1);//{haha: "hahahahahahah"}
54+
55+
//jQuery的AJAX;
56+
/*var options={
57+
url:"babababab",
58+
type:"",
59+
date:{}
60+
};
61+
$.ajax(options);*/
62+
63+
64+
function Test(opt) {
65+
//bala bala
66+
}
67+
var testVal=Test({a:"",b:""});
68+
69+
//Array;
70+
var a=[1,2,3,4,5,6,7];//var a=[1,2,3,4,5,6,7,] 低版本浏览器,length的;
71+
console.log(a);//编程语言里,index是以0为开始的;
72+
console.log("第一位,a[0]",a[0]);
73+
console.log(a[1]);
74+
console.log(a.length);//7
75+
76+
// -> //
77+
78+
</script>
79+
</body>
80+
</html>
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Title</title>
6+
</head>
7+
<body>
8+
9+
<script>
10+
//string 单引号'' / 双引号""包裹的内容
11+
/*alert(typeof "22");
12+
alert(typeof '22');
13+
alert(typeof "");
14+
alert(typeof '');*/
15+
console.log(typeof "22");
16+
console.log(typeof '2');
17+
console.log(typeof '');
18+
console.log(typeof "");
19+
console.log(typeof "false");
20+
21+
console.log(typeof "null");
22+
23+
//length,一般作为用户输入店名/用户名的长度限制;需要注意双字符精准度的问题;
24+
var str="123123123123123123123123123123";
25+
var chinaStr="哈喽";//双字节,不精确 4字节;
26+
console.log(str.length);
27+
console.log(chinaStr.length);//2
28+
29+
//字符串创建的原理;
30+
var str1="12345";//把"12345"这个字符串赋值给str1这个变量;
31+
str1="1234";//把"1234"这个字符串赋值给str1这个变量;
32+
/*
33+
* 并不是把"12345"修改为"1234"然后赋值给str1
34+
*
35+
* */
36+
console.log(str1);//"1234"
37+
console.log('1"23\'4\n56\'78');
38+
// alert("1213123\naaaaaa")
39+
40+
//toString方法;
41+
//22 - > "22"
42+
console.log(typeof 22);
43+
console.log(typeof (22).toString());
44+
var testStr=22+"";//隐式调用toString方法
45+
console.log(typeof 22+"");//+ - * / 2*2+10
46+
console.log(typeof testStr);//2*(2+10)
47+
48+
//eval()
49+
console.log("00000000000000000");
50+
console.log(eval("22+12"));//"22+12" -> 22+12 ->34
51+
52+
53+
//
54+
console.log("**********************");
55+
console.log(typeof (22+""));//string 22 -> "22"
56+
console.log(typeof (+"22"));//"22" -> 22 单目运算符+
57+
58+
59+
</script>
60+
</body>
61+
</html>

0 commit comments

Comments
 (0)