Javascript basic finishing (ES5)

Javascript主要分为ECMAScript + DOM + BOD


Preface

输出语句

  • console.log() is actually the method under window.console.log() window object
  • alert() is actually the method under window.alert() window object

REPL环境

  1. Read
  2. Eval execution
  3. Print
  4. Loop

前端三层

  1. Structural layer
  2. Style layer
  3. Behavioral layer

*variable

定义变量

The var keyword defines a variable or defines multiple variables at the same time, separated by ','

When
the variable defined by var a is not assigned an initial value, the default value is undefined

have b = 13
关键字 变量 赋值运算符 值

var c = 13, d = 15
define multiple variables at the same time

变量的提升

  • Only promote the variable name, not the value
  • Before executing all the code, JS has a pre-analysis stage, which will pre-read the definition of all variables. This is the reason why variables can be improved.

变量的使用

console.log(a)
变量使用时不能加引号

改变变量的值

When changing the value of a variable, there is no need to write the keyword var, just assign the value by the assignment operator

变量的命名规则

  1. Only in 字母, 下划线, 数字, $symbols,Cannot start with a number
  2. No keywords or reserved words
  3. Case sensitive, a and A are different

Variable naming rules also apply to identifier naming rules
Identifiers: functions, class names, object attributes, etc.

Excellent variable nomenclature
1, 驼峰命名法mathTestScore
2, c风格math_test_score

变量常见错误

  • Without var definition, although no error will be reported, the variable will become a global variable, which will cause scope problems
  • Use a variable that is neither defined nor assigned, an error will be reported (reference error)

*type of data

数据类型简介和检测

Two data types in JS: basic type with Reference type

typeofOperator detects the type of value or variable

typeof 5    //number
typeof null    //object
type of NaN     //number
typeof undefined   //undefined

Values ​​of the null data type and undefined data type, only the respective null and undefined

基本数据类型

  1. String type

    Strings are spliced ​​with + sign

    The length attribute of the string can indicate the length of the string

    var a='123'
    console.log(a.length)    //输出4
    

    String common methods

  2. Number type

    0 in decimals can be omitted

    Scientific notation: 3e8 is the same as 3 times 10 to the 8th power
    较大数或者较小数可以写成科学计数法 ,如3e8,或3e-8

    NaN
    special number type value, not a number

  3. Boolean type

  4. null type

  5. undefined type

复杂数据类型简介(引用数据类型)

  1. Array
  2. Object

*Expressions and operators

JS基本表达式

Arithmetic expression

Arithmetic expression

JS运算符


*JS flow control statement

条件语句

循环语句


*algorithm

什么是算法

累加器和累乘器

穷举法

综合算法


*Array

数组简介及定义/数组类型检测

数组常用方法

数组算法

Traverse related algorithms
Array deduplication and random samples
Bubble Sort
Two-dimensional array

数组的深浅克隆

Memory change of basic type value passing by value (stack storage)
Memory change of reference type value passing by value (heap storage)
Shallow clone
Deep clone

*function

函数基本使用

What is a function
Function definition and call
Function parameters and return values

函数算法题

递归

作用域和闭包

立即执行函数

Guess you like

Origin blog.csdn.net/m0_46440007/article/details/113121334