Getting started with JS

js

Basic use

  1. Introduce external js files (no need to write js code inside)
  2. Add in tags
<a href = "Javascript:alert('标签内的')">百度</a>
  1. Event based
<p onclick = "alert('基于事件的')">基于事件的</p>
  1. Write in the script notes
Three commonly used output methods in JS
  1. Console output console.log
  2. Alert()
  3. 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
  1. Variable naming is composed of numbers, letters, underscores, and $, but cannot start with a number
  2. Variables are case sensitive. Name and name are not a variable
  3. Variable naming, try to be meaningful, you can use English words
  4. Hump ​​nomenclature
    Small hump fristName
    Big hump FristName

Comment
Single-line comment
Multi-line comment (be careful not to nest multi-line comments)

Guess you like

Origin blog.csdn.net/weixin_50709247/article/details/109430243