Học JavaScript qua ví dụ part 20

Đối tượng Đối tượng là gì? JavaScript là tất cả về đối tượng. Windows và các nút, hình thức và hình ảnh, liên kết và neo được tất cả các đối tượng. Ngôn ngữ lập trình như Java, C + +, và Python tập trung vào các đối tượng được gọi là lập trình hướng đối tượng (OOP) ngôn ngữ. JavaScript được gọi là một ngôn ngữ dựa trên đối tượng vì nó không đáp ứng các tiêu chuẩn kỹ thuật của nhiều ngôn ngữ nặng, nhưng chắc chắn nó hoạt động như một ngôn ngữ hướng đối tượng | chapter 8 Objects What Are Objects JavaScript is all about objects. Windows and buttons forms and images links and anchors are all objects. Programming languages like Java C and Python that focus on objects are called object-oriented programming OOP languages. JavaScript is called an object-based language because it doesn t technically meet the criteria of the more heavy-duty languages but it certainly behaves as an object-oriented language. Some people are apprehensive at the thought of tackling this kind of programming although the mystique is somewhat diminished from what it was back in the last century when the top-down procedural approach to programming was more in vogue. In the real world you may see a book or a cup or a hat as an object. JavaScript can represent data such as a string or a number as an object and JavaScript lets you create your own objects. When talking about JavaScript data types in Chapter 3 The Building Blocks Data Types Literals and Variables we discussed two types primitive and composite. Objects are composite types. They provide a way to organize a collection of data into a single unit. Object-oriented languages such as C and Java bundle up data and behavior and call it an object. So does JavaScript. When you learn about objects they are usually compared to real-world things like a cat a book or a triangle. Using the English language to describe an object the object itself would be like a noun. Nouns are described with adjectives. A cat might be described as fat furry smart or lazy. The book is old with 400 pages and contains poems. The triangle has three sides three angles and red lines. The adjectives that collectively describe these objects are called properties or attributes. The object is made up of a collection of these properties or attributes. In English verbs are used to describe what the object can do or what can be done to it. The cat eats sleeps and meows. The book is read its pages can be turned forward and backward and

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.