js small knowledge piece together

1. Symbol is also one of the basic data types

2. What problem does Promise solve?

Answer: To solve the problem of callback function callback hell, it becomes a chain operation through .then().then

3. Each time a request is made, the cookie will send data to the server, localStorage and sessionStorage will not, so cookies are not very performance-friendly and occupy bandwidth

4. git command related

git diff // 查看改动了哪些(全部)
git diff 文件 // 查看具体哪个文件改动了什么
git show 提交id // 查看提交改动
git fetch // 拉取远程所有分支

For example, git show 4eb10efe3178b839777c135b6cb08190fcaa0cd3

5. DOM rendering and js loading and parsing cannot be performed at the same time, because DOM rendering and js loading and parsing share the same thread

6. If there is a string, concatenate according to the string

console.log(true + '10') // 'true10'

7. What is the development environment?

8. onload 和 DOMContentLoaded

// 页面全部加载完毕触发 包括页面的html、css、js、图片等资源都已经加载完
    window.onload = function () {
      console.log('load')
    }

    // HTML 文档被完全加载和解析完成之后,而无需等待样式表、图像和子框架的完成加载。
    document.addEventListener('DOMContentLoaded', () => {
      console.log('DOMContentLoaded')
    })

Note: onload is mounted on the window, and DOMContentLoaded is mounted on the document

Trigger DOMContentLoaded first, then onload

Guess you like

Origin blog.csdn.net/Luckyzhoufangbing/article/details/108579274