File tree 1 file changed +8
-8
lines changed
1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -111,26 +111,26 @@ console.log(12 | 5); //返回值13
111
111
112
112
![ img] ( ..\images\按位或.gif )
113
113
114
- ### 2.2 右移操作符
114
+ ### 2.2 左移操作符
115
115
116
- ** 右移操作符 (` >> ` )** 是将一个操作数按指定移动的位数向右移动 。
116
+ ** 左移操作符 (` << ` )** 是将一个操作数按指定移动的位数向左移动 。
117
117
118
118
``` ts
119
- 1 >> 1 // 0001 -> 0010
119
+ 1 << 1 // 0001 -> 0010
120
120
121
- 1 >> 3 // 0001 -> 1000
121
+ 1 << 3 // 0001 -> 1000
122
122
```
123
123
124
124
### 2.3 实现 v2 版本
125
125
126
- 通过对于按位与、按位或和右移操作符的理解 ,我们不难想象,可以将一个 shapeFlag 修改为下面这样:
126
+ 通过对于按位与、按位或和左移操作符的理解 ,我们不难想象,可以将一个 shapeFlag 修改为下面这样:
127
127
128
128
``` ts
129
129
const ShapeFlags = {
130
130
element: 1 , // 0001
131
- stateful_component: 1 >> 1 , // 0010
132
- text_children: 1 >> 2 , // 0100
133
- array_children: 1 >> 3 , // 1000
131
+ stateful_component: 1 << 1 , // 0010
132
+ text_children: 1 << 2 , // 0100
133
+ array_children: 1 << 3 , // 1000
134
134
}
135
135
```
136
136
You can’t perform that action at this time.
0 commit comments