Coffeescript 简明教程
CoffeeScript - Data Types
CoffeeScript Data Types
编程语言最重要的特性之一是它支持的数据类型集。这些类型的值可以在编程语言中表示和操纵。
One of the most fundamental characteristics of a programming language is the set of data types it supports. These are the type of values that can be represented and manipulated in a programming language.
CoffeeScript 逐行编译为 JavaScript,因此 CoffeeScript 提供的数据类型与 JavaScript 相同。除了 CoffeeScript 增加了某种额外精髓的事实。
As CoffeeScript compiles line by line to JavaScript, the data types provided by CoffeeScript are same as JavaScript. Except for the fact that CoffeeScript adds some additional essence.
CoffeeScript 提供了下列数据类型供使用 −
CoffeeScript provides the following data types to work with −
-
Strings − The String data type represents a group of characters in general and we represent a string value with in-between double quotes (" "). Example: "Raj", "Rahman"
-
Number − The number data type represents the numerical values. Example: 12, 212, etc.
-
Boolean − Boolean data type represents one bit of information. There are only two possible values: true and false.
-
Arrays − The Array object lets you store multiple values in a single variable. It stores a fixed-size sequential collection of elements of the same type. Example: student = ["Rahman","Ramu","Ravi","Robert"]
-
Objects − The Objects in CoffeeScript are similar to those in JavaScript these are collection of the properties. Where a property includes a key and a value separated by a semi colon (:). In short, CoffeeScript objects are a collection of key-value pairs. Example: student = {name: "Mohammed", age: 24, phone: 9848022338 }
-
Null − A variable that is defined and does not hold any value is considered and null. This is similar to the null value in JavaScript.
-
Undefined − A variable which hasn’t had any value assigned to it is considered as undefined variable. If you use such variables in your code, then you will get an undefined error.
我们将在单独章节中详细介绍数据类型数组和对象。
We will cover the data types Arrays and Objects in detail in separate chapters.