js
Basic use
- Introduce external js files (no need to write js code inside)
- Add in tags
<a href = "Javascript:alert('标签内的')">百度</a>
- Event based
<p onclick = "alert('基于事件的')">基于事件的</p>
- Write in the script notes
Three commonly used output methods in JS
- Console output console.log
- Alert()
- Output text content document.write() / window.document.write()
variable
In fact, it is a container
js weakly typed language. What type of value is stored in the variable, then what type is the variable.
If a variable is declared without a value, his system will give him a default value of undefined
Variable naming
- Variable naming is composed of numbers, letters, underscores, and $, but cannot start with a number
- Variables are case sensitive. Name and name are not a variable
- Variable naming, try to be meaningful, you can use English words
- Hump nomenclature
Small hump fristName
Big hump FristName
Comment
Single-line comment
Multi-line comment (be careful not to nest multi-line comments)