与Python一样,Js也是一门解释型动态语言,解释型的意思是它只有runtime, 没有compile time. 动态主要体现在:
- 动态类型,数据类型并未绑定到变量上,而是绑定在object上,变量相当于object的一个标签,对变量赋值不是改变它指向的object,而是将变量绑定到一个新的object上
- 动态namespace, name resolution发生在执行的时候,是根据执行时的namespace确定的,而不是根据静态的context确定
- 动态的object model, 这个与namespace相似,一个object的属性可以动态地增、删。
Variable scope, variable hoisting, funciton hoisting
Js is loosly typed, it has implicit type conversion.
Types
八大类型(前7种是primitive):
- boolean
- number: double-precision 64-bit floating point,
- string: immutable
- null:
typeof(null) === object
you can consider it a bug - undefined
- BigInt
- Symbol
- object: include array, function (typeof instance == function)
Javascript: Key points and Hard parts
- types, values
- scope, closure, this
- prototype chain, class
- single thread, callback, event loop
- promise, async, generator