心智通俗来讲是我们看待人和事的态度,以及由此作出的判断与选择,每个人来到世界上时,其人生观、世界观、价值观全部是从零开始,你、我、我们的父辈、孩子都是如此,没有人能直接跨越这一阶段。而不少人的初始状态是混沌的,他们天然的追求简单、轻松、舒适、确定,这种天性支配着他们,成为他们喜怒哀乐的生理起点,然而深陷其中的大多数人对此知之甚少。
如果不出意外,大多数人都会沿着“求学-工作-婚恋”的路线成长,随着生活的惯性一直往前走。年轻的时候,现在应该是在高中时期,几乎没有人会觉得自己将来
能有多差,认定美好的生活会自然到来。不谙世事的我们认为:即时暂时说不清具体该怎么做,但有份十足的信心就够了,毕竟年轻无敌嘛。
在高中的时候身为小城市的学生对这个世界的运行规则浑然不只,不知道事物的构成、框架、不知道努力的路径、方法,也不知道自己真正想要什么、能做什么、最后会成为什么样的人,父母并不能给我足够宽的视野,在小地方并不知道英语的重要性,看不到顶级大学与普通大学的差距。在进入社会后,在不断的服从社会规则和应对生活烦恼,开始随波逐流:该玩手机玩手机、该打游戏打游戏;没有多少压力,也没有多少动力;

More on Functions

Function Type Expressions

The simplest way to describe a function is with a function type expression.

1
2
3
4
5
6
7
8
9
10
function greeter(fn: (a: string) => void) {
fn("Hello, Word");
}

function printToConsole(s: string) {
console.log(s);
}

greeter(printToConsole);

we can use a type alias to name a function type:

1
2
3
4
5
type GreetFunction = (a: string) => void;

function greeter(fn: GreetFGunction) {
// ...
}

The primitives: string, number, and boolean

  • string represents string values like "hello world"
  • number is for numbers like 32,no equivalent to int or flaot - everything is simply number.
  • boolean is for the two values true,and false.

Arrays

To specify the type of an array like [1,2,3] use number[]

Type Annotations on Variables 变量的类型注解

1
2
let name: string = "Alice";
// In most cases, though, this isn't needed. TS tries to automatically infer the types in your code.

Functions

1
2
3
4
5
function greet(name: string) {
console.log("Hello" + name.toUpperCase() + "!");
}
// error, paramter need a string.
greet(34);

return type

1
2
3
function getNumber(): number {
return 32;
}

js中的运算权重。括号运算 > 普通运算 > 赋值

+ - * /

  1. 加法运算 +,
    1. 包含数字的数学运算,
    2. 字符串拼接,字符串加任何数据类型都转换为字符串
  2. 除法运算 /
    1. c = 0 / 0, c为NaN
    2. 0 / 0 // NaN not a number,
    3. 1 / 0 // infinity
    4. -1 / 0 // -infinity
  3. 取模运算:%
  4. 乘法运算:*

交换值的问题

1
2
3
4
5
var a = 3,
b = 4;
a = a + b; // 7
b = a - b; // 3
a = a - b; // 4

5大浏览器的内核

  1. IE ——-> trident
  2. Chrome —-> webkit---> blink
  3. Safari ——-> webkit
  4. Firefox ——> gecko
  5. Opera ——-> presto--->webkit--->blink

浏览器的历史与JS的诞生

  1. 1990年
    1. 蒂姆 伯纳斯 李,通过超文本分享资讯,他开发了一个叫做 world wide web,并且移植到C语言上,更名为libwww/nexus,已经可以实现允许他人浏览他编写的网站,此时可以称作真正的浏览器。
  2. 1993年
    1. 在美国伊利诺大学,NCSA组织的(马克安德森),开发了MOSIAC浏览器,这时已经可以显示图片,成为图形化浏览器
  3. 1994年
    1. 马克安德森与硅图SGI的吉姆克拉克成立了MOSIAC communication corporation,由于商标权,MOSICA的商标权属于伊利诺大学并且转给了 spy glasss公司,所以他们更名为Netscape communication corporation
    2. 也就是后来的网景公司
    3. 网景公司开发了netscape navigator流行了十年左右,直到2003年
  4. 1996年
    1. 微软公司收购spy glass
    2. 通过MOSIAC开发出IE,internet explorer 1.0
    3. 在同一年发布了IE3,与脚本_JScript_
    4. 网景公司Brendan eich在NETSCAPE NAVIGATOR,开发出来livescript。这个时候js是没有单独的引擎的,脚本的性能非常低
    5. JAVA火起来了之后,网景公司与java所有方SUN公司合作推广宣传产品,
    6. livescript更名为—–>javascript
  5. 2001年
    1. IE6 XP 诞生,JS引擎出现
  6. 2003年
    1. mozilla公司,开发了firefox -> netscape navigator
  7. 2008年
    1. google 基于 WEBKIT BLINK GEARS
    2. 开发出chrome浏览器
    3. v8引擎
    4. javascript引擎
    5. v8引擎直接翻译机器码
    6. 独立于浏览器运行
  8. 2009年
    1. 甲骨文oracle收购SUN公司,JS的所有权归于甲骨文

webpack 是一个开源的JavaScritpt模块打包工具,其最核心的功能是解决模块之间的依赖,将各个模块按照特定的规则和顺序组织在一起,这个过程叫做模块打包

模块打包原理

一个最简单的Webpack打包结果(bundle)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// index.js
const calculator = require('./calculator.js');
const sum = calculator.add(2, 3);
console.log('sum', sum);

// calculator.js
module.exports = {
add: function(a, b) {
return a + b;
}
};

// 立即执行匿名函数
(function(modules) {
//模块缓存
var installedModules = {};
// 实现require
function __webpack_require__(moduleId) {
...
}
// 执行入口模块的加载
return __webpack_require__(__webpack_require__.s = 0);
})({
// modules:以key-value的形式存储所有被打包的模块
0: function(module, exports, __webpack_require__) {
// 打包入口
module.exports = __webpack_require__("3qiv");
},
"3qiv": function(module, exports, __webpack_require__) {
// index.js内容
},
jkzz: function(module, exports) {
// calculator.js 内容
}
});