语言特性
- single thread的语言
- 弱类型语言,一个变量可以赋不同数据类型的值,这让一路学了C/C++/Java和python的人表示有点抓狂,据说微软的小伙伴们解决了这个问题,拭目以待
基本语法
- 变量
变量命名为CamelCasing写法
变量类型:Numbers, Strings, Booleans, Objects, Arrays - Control Flow
- if (==数字和chart视为相等, ===数字和chart不视相等)
It does what's called coercion and we'll talk about that below. But in an example 2 == "2" but it does not 2 === "2". String 2 is double equal to number 2 but string 2 is not triple equal to number 2.- loop
- while
- for
- 函数function其命名一般是动词,函数的参数一般是名词
- Builtins 内建函数,如toUpperCase()
- this
Context,refers to me - DOM
javascript和html/css交互的方式, DOM中都是Stirng没有number
函数式编程
使用function这个内建函数
const cities = [
"Seattle",
"San Francisco",
"Salt Lake City",
"Amsterdam",
"Hong Kong"
];
// method 1
for (let i = 0; i < cities.length; i++) {
console.log(cities[i]);
}
// method 2
cities.forEach(function(city) {
console.log(city);
});
AJAX
https://zhuanlan.zhihu.com/p/22564745
ES6(ECMAScript2015)
http://www.alloyteam.com/2016/03/es6-front-end-developers-will-have-to-know-the-top-ten-properties/
- 解构赋值
- 箭头函数
串烧编码的过程
- 先写html的元素,再写CSS改变布局和样式,然后加javascript的逻辑
- 加javascript逻辑时,先理清全局变量,然后break down,一个个函数地写。每写一个,都测试一下,是否work
- debug时,先看是否进入函数,用console.log,然后再确认调用的变量的名称,是否一致(这个经常typo error)