LEARNING JAVASCRIPT - Trang 11

9.

Objects and Object-Oriented Programming. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147

Property Enumeration 147

for...in 148

Object.keys 148

Object-Oriented Programming 149

Class and Instance Creation 150

Dynamic Properties 151

Classes Are Functions 152

The Prototype 153

Static Methods 155

Inheritance 156

Polymorphism 157

Enumerating Object Properties, Revisited 158

String Representation 159

Multiple Inheritance, Mixins, and Interfaces 159

Conclusion 161

10.

Maps and Sets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163

Maps 163

Weak Maps 165

Sets 166

Weak Sets 167

Breaking the Object Habit 167

11.

Exceptions and Error Handling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169

The Error Object 169

Exception Handling with try and catch 170

Throwing Errors 171

Exception Handling and the Call Stack 171

try...catch...finally 173

Let Exceptions Be Exceptional 174

12.

Iterators and Generators. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175

The Iteration Protocol 177

Generators 179

yield Expressions and Two-Way Communication 180

Generators and return 182

Conclusion 182

13.

Functions and the Power of Abstract Thinking. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183

Functions as Subroutines 183

Functions as Subroutines That Return a Value 184

Table of Contents | ix

Liên Kết Chia Sẽ

** Đây là liên kết chia sẻ bới cộng đồng người dùng, chúng tôi không chịu trách nhiệm gì về nội dung của các thông tin này. Nếu có liên kết nào không phù hợp xin hãy báo cho admin.