From 7dd4ae0891247ddaf3d374389f2fc442e9cd3410 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E8=B6=85?= <9828390+wu-chao24@user.noreply.gitee.com> Date: Sun, 9 Oct 2022 13:57:49 +0000 Subject: [PATCH 1/4] =?UTF-8?q?=E6=96=B0=E5=BB=BA=2030=E5=90=B4=E8=B6=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "30\345\220\264\350\266\205/.keep" | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 "30\345\220\264\350\266\205/.keep" diff --git "a/30\345\220\264\350\266\205/.keep" "b/30\345\220\264\350\266\205/.keep" new file mode 100644 index 0000000..e69de29 -- Gitee From 2809acfd418ffd1e651b8704a58152ed80303158 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E8=B6=85?= <9828390+wu-chao24@user.noreply.gitee.com> Date: Sun, 9 Oct 2022 13:58:06 +0000 Subject: [PATCH 2/4] =?UTF-8?q?=E6=96=B0=E5=BB=BA=20=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "30\345\220\264\350\266\205/\344\275\234\344\270\232/.keep" | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 "30\345\220\264\350\266\205/\344\275\234\344\270\232/.keep" diff --git "a/30\345\220\264\350\266\205/\344\275\234\344\270\232/.keep" "b/30\345\220\264\350\266\205/\344\275\234\344\270\232/.keep" new file mode 100644 index 0000000..e69de29 -- Gitee From a6e1edd9c3b65f7587c0323fcc0d56c2acd8fc24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E8=B6=85?= <9828390+wu-chao24@user.noreply.gitee.com> Date: Sun, 9 Oct 2022 13:58:17 +0000 Subject: [PATCH 3/4] =?UTF-8?q?=E6=96=B0=E5=BB=BA=20=E7=AC=94=E8=AE=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "30\345\220\264\350\266\205/\347\254\224\350\256\260/.keep" | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 "30\345\220\264\350\266\205/\347\254\224\350\256\260/.keep" diff --git "a/30\345\220\264\350\266\205/\347\254\224\350\256\260/.keep" "b/30\345\220\264\350\266\205/\347\254\224\350\256\260/.keep" new file mode 100644 index 0000000..e69de29 -- Gitee From a0412d480e689049b1afe465b62fc082f6862365 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E8=B6=85?= <9828390+wu-chao24@user.noreply.gitee.com> Date: Sun, 9 Oct 2022 14:12:56 +0000 Subject: [PATCH 4/4] =?UTF-8?q?=E7=AC=94=E8=AE=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 吴超 <9828390+wu-chao24@user.noreply.gitee.com> --- .../10.6js\345\237\272\347\241\200.md" | 146 ++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 "30\345\220\264\350\266\205/\347\254\224\350\256\260/10.6js\345\237\272\347\241\200.md" diff --git "a/30\345\220\264\350\266\205/\347\254\224\350\256\260/10.6js\345\237\272\347\241\200.md" "b/30\345\220\264\350\266\205/\347\254\224\350\256\260/10.6js\345\237\272\347\241\200.md" new file mode 100644 index 0000000..c35c3a6 --- /dev/null +++ "b/30\345\220\264\350\266\205/\347\254\224\350\256\260/10.6js\345\237\272\347\241\200.md" @@ -0,0 +1,146 @@ +## js基础 + +JS是支持面向对象编程的跨平台脚本弱类型的语言 + +面向对象是一种思想 + +跨平台:ios、Android、windows、Linux + +脚本:依赖其他才能解析 + +弱类型:变量在声明后还可以改变 + +## 变量 + +一、var是声明变量的关键字 。 + +二、给变量命名的时候,需要遵循如下规则: + +【1】 第一个字符必须是一个字母、下划线(_)或一个美元符号$。 + +【2】 后面的字符可以是字母、下划线、美元符号或数字。 + +【3】 区分大小写。 + +【4】 不能与关键字同名 ,如while、for和if等。 + +## js的输出方式 + +``` +alert()  //浏览器弹窗、用户提示 +document.write()  //可在浏览器的显示区域显示文本 +console.log()  //控制台日志 +confirm()  //提示用户下一步操作 +prompt()  //用于提醒用户输入 +``` + +## 数据类型的分类 + +``` +number  //数字型 +string  //字符串类型(加了引号都是字符串) +undefind  //未定义(只声明为赋值) +Boolean  //布尔类型 +object  //对象(数组、对象、null) +``` + +### 转化为数字类型方法 + +``` +Number() +parseInt()  //转为数字类型并取整 +parseFloat()  //转化为浮点数保留小数 +Math.round()  //小数后一位四舍五入进行取整 +.toFixed(3)  //保留三位小数 +``` + +### 布尔类型转化为数字 + +``` +Number()和Math.round()  //会转化为1或者0 +parseInt()和parseFloat()   //会显示为NaN (not a number) +``` + +### 将undefined转化为数字 + +``` +所有方法都会显示NaN +``` + +### 将null转化为数字 + +``` +Number()和math.round()  //会转化为0 +parseInt()和parseFloat()  //会显示NaN +``` + +### 转化为字符串方法 + +``` +String() +被转换的数据.tostring() + +undefiend转换为字符串   .tostring会报错 +null转换为字符串   .tostring会报错 +其它类型转字符串类似加上引号正常显示 +``` + +### 转换为布尔类型方法 + +``` +Boolean() +数字中除了0都是true +字符串中有内容都为true,无内容都为false +undefiend和null都为false +``` + +# JS代码编写位置 + +``` +//(1)直接写在页面标签里面 + + + + + 脚本代码的位置:直接写在页面标签里面 + + + + + + + +//(2)写在外部JS文件中 + +//js外部文件: +alert("欢迎进入JavaScript编程的世界!"); + +//html文件 + + + + 脚本代码的位置:写在外部js文件中 + + + + + + + +//三、将JS脚本代码作为A标签的属性值 + + + + + 将脚本代码作为a标签的属性值 + + + + 喜欢我就点击我吧 +

+ 喜欢我就点击我吧 + + +``` \ No newline at end of file -- Gitee