随笔分类 -  JavaScript[ES6]

摘要:1. 默认绑定 // 全局环境指向window console.log(this); // 函数独立调用,函数内部this指向window function fn() { console.log(this); } fn(); // 函数当做对象方法来调用,this指向对象 var x = 666; 阅读全文
posted @ 2022-11-11 12:58 LeoShi2020 阅读(16) 评论(0) 推荐(0) 编辑
摘要:1. 闭包函数 // 闭包函数 var a = 123; function f1() { console.log(a); var b =234; function f2() { console.log(b); } return f2; } // 打印a 123 result 被赋值为f2函数 var 阅读全文
posted @ 2022-11-10 17:53 LeoShi2020 阅读(30) 评论(0) 推荐(0) 编辑
摘要:1. 执行流 // 执行流 var a = 1; // 1 var b = 2; // 2 function fn(x) { var a = 10; // 4 function bar(x) { // 6 // 11 var a = 100; // 7 a=100 // 12 a=100 b = x 阅读全文
posted @ 2022-11-10 17:07 LeoShi2020 阅读(28) 评论(0) 推荐(0) 编辑
摘要:1. 网页源码 <body> <header class="text-center"> <h1>JavaScript_DOM</h1> </header> <section class="container"> <div class="form p-4 bg-dark text-light text 阅读全文
posted @ 2022-11-10 16:12 LeoShi2020 阅读(21) 评论(0) 推荐(0) 编辑
摘要:1. 面向对象 // 大括号就是对象 p = { a:1, b:2, c:3, } // 系统对象全部基于window // console.log(window); // window.alert(1); // alert(2); // console.log(navigator.appVersi 阅读全文
posted @ 2022-11-10 12:05 LeoShi2020 阅读(19) 评论(0) 推荐(0) 编辑
摘要:1. 函数 function addNums(num1=1,num2=2) { console.log('num1 + num2:',num1 + num2); return num1 + num2; } addNums(); addNums(5,6); console.log('addNums() 阅读全文
posted @ 2022-11-09 23:53 LeoShi2020 阅读(22) 评论(0) 推荐(0) 编辑
摘要:1. Switch // Switch 语句 const color = 'green'; switch (color) { case 'red': console.log('color is red'); break; case 'blue': console.log('color is blue 阅读全文
posted @ 2022-11-09 23:24 LeoShi2020 阅读(12) 评论(0) 推荐(0) 编辑
摘要:1. 语句 // if 语句 let x = 10; if (x == 10) { console.log('x is 10') }; // if else if else x = 20; if (x 10) { console.log('x is 10'); } else if (x > 10) 阅读全文
posted @ 2022-11-09 23:19 LeoShi2020 阅读(35) 评论(0) 推荐(0) 编辑
摘要:1. 语句 // For语句 for (let index = 0; index <=6; index++) { console.log(`For Loop Number:${index}`); } // While语句 let i = 0; while (i <=6) { console.log( 阅读全文
posted @ 2022-11-09 23:03 LeoShi2020 阅读(17) 评论(0) 推荐(0) 编辑
摘要:1. 变量 // Javascript常用变量类型 // numbers,string,boolean, // Object:Array,Undefined,null // const 常量不能修改 // let和var 变量可修改 const name ="Tom"; const age = 22 阅读全文
posted @ 2022-11-09 22:31 LeoShi2020 阅读(35) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示