English 中文(简体)
CoffeeScript - Data Types
  • 时间:2024-12-22

CoffeeScript - Data Types


Previous Page Next Page  

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.

As CoffeeScript compiles pne by pne to JavaScript, the data types provided by CoffeeScript are same as JavaScript. Except for the fact that CoffeeScript adds some additional essence.

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.

Advertisements