webveuje/js/kejian/jsinfo - 副本.md
2021-03-23 10:58:10 +08:00

2.1 KiB
Raw Blame History

js info

预编译

链接:

this 指向

https://www.cnblogs.com/pssp/p/5216085.html

demo1:

function f() {
    console.log(aa); // undefined
    var aa = 5;
    console.log(aa); // 5
}
f();

demo2:

var scope = 'global';
function t() {
    console.log(scope); // undefined
    var scope = 'local';
    console.log(scope); // local
}
t();
console.log(scope); // global

demo3:

console.log(b) //undefined 变量提升
var b =2; 

demo4

console.log(foo)
function foo(){
    
}
var foo =1

作用域

demo1:

function zxxFn () {
    zxxs = 2
}
var zxx = 1
console.log(window.zxx) // 1
// console.log(zxxs) 未定义
zxxFn() // 执行后zxxs成为全局变量
console.log(zxxs) // 2

var zxx = 'zxx is a good girl'
    function zxxFn () {
        console.log(zxx) 
        var zxx = 'zxx is a great girl'
        console.log(zxx)
        zxx = 'very good'
        console.log(zxx)
    }
    console.log(zxx)
    zxxFn()
    console.log(zxx)
    // 依次输出 1. zxx is a good girl 2. undefined 3. zxx is a great girl
    // 4. very good 5.zxx is a good girl
zxxAge = 'zxx is 18 years old'
function zxxFn () {
    console.log(zxxAge)
    var zxxAge = 'zxx is 8 years old'
    var zxxSub = 'zxx is 25 years old'
    console.log(zxxAge) // zxx is 8 years old
    // console.log(zxxSub) // zxxSub is not defined
    function zxxFnSub () {
        var zxxSub = 'zxx is 18 years old'
        console.log(zxxSub) // zxx is 18 years old 
        console.log(zxxAge) // zxxSub is not defined
    }
    zxxFnSub()
}
zxxFn()

js dom

js dom 初识: https://juejin.cn/post/6907112616221966350

js dom操作 https://juejin.cn/post/6844903593011576845

jq dom操作

作业:

通过在页面上点击button实现主题切换 主题1黑底白字 主题2粉底绿字

五环之歌

点击按钮显示一个五行四列的表格 内容自定义

自定义一个6行的ul列表 点击删除

dom事件

https://www.w3school.com.cn/js/js_htmldom_events.asp