tailieunhanh - Học JavaScript qua ví dụ part 8

Các loại dữ liệu Composite Chúng tôi đã đề cập rằng có hai loại dữ liệu: nguyên thủy và composite. Chương này tập trung vào các loại nguyên thủy: số, chuỗi, và Booleans-mỗi lưu trữ một giá trị duy nhất. Tổng hợp các loại dữ liệu, còn được gọi là loại phức tạp, bao gồm nhiều thành phần. Đối tượng, mảng, và chức năng, tả sau này trong cuốn sách này, tất cả đều chứa một bộ sưu tập của các thành phần. Đối tượng chứa các thuộc tính và phương pháp, mảng chứa danh sách liên tục của các yếu. | Variables 59 Figure Output from Example . Composite Data Types We mentioned that there are two types of data primitive and composite. This chapter focuses on the primitive types numbers strings and Booleans each storing a single value. Composite data types also called complex types consist of more than one component. Objects arrays and functions covered later in this book all contain a collection of components. Objects contain properties and methods arrays contain a sequential list of elements and functions contain a collection of statements. The composite types are discussed in later chapters. Variables Variables are fundamental to all programming languages. They are data items that represent a memory storage location in the computer. Variables are containers that hold data such as numbers and strings. Variables have a name a type and a value. num 5 name is num value is 5 type is numeric friend Peter name is friend value is Peter type is string The values assigned to variables can change throughout the run of a program whereas constants also called literals remain fixed. JavaScript variables can be assigned three types of data numeric string Boolean Computer programming languages like C and Java require that you specify the type of data you are going to store in a variable when you declare it. For example if you are going to assign an integer to a variable you would have to say something like int n 5 From the Library of 60 Chapter 3 The Building Blocks Data Types Literals and Variables And if you were assigning a floating-point number float x Languages that require that you specify a data type are called strongly typed languages. JavaScript conversely is a dynamically or loosely typed language meaning that you do not have to specify the data type of a variable. In fact doing so will produce an error. With JavaScript you would simply say n 5 x and JavaScript will figure out what type of data is being stored in n and x. .

TỪ KHÓA LIÊN QUAN
crossorigin="anonymous">
Đã 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.