官术网_书友最值得收藏!

  • The JavaScript Workshop
  • Joseph Labrecque Jahred Love Daniel Rosenbaum Nick Turner Gaurav Mehla Alonzo L. Hosford Florian Sloot Philip Kirkbride
  • 404字
  • 2021-06-11 12:53:02

Fixed Types

Fixed types are types that have no variation of value. Unlike numbers, which may have any combination of digits, an optional minus sign (for negative numbers), a decimal point, or a scientific notation, a fixed type is always one simple value or value group.

In JavaScript, the available fixed types include null, undefined, and Booleans (true and false). These values are static and cannot change. If a variable contains one of these values, it is then strictly equal to the value itself. Fixed types are more of a representation of a situation than actual data. For instance, true is a fixed representation of truthfulness and false is a fixed representation of falsehood. The values are not quantifiable in the real world but are representative of logic that software directly deals with.

The null Value

null, in mathematical terms, denotes a value that is not present. In JavaScript, null is a static value that's used to mean no value. In other languages, this would be equivalent to nil or void.

null is a useful value for dereferencing variables or for returning a value from a function when no value can be returned. For instance, a function may return an object from an array if the item is present but may return null if it is not.

The undefined Value

undefined is similar to null in many ways and, due to this, the two values are often misused. undefined is the value contained in any variable that is declared first, but not assigned a value. It is also the value that's been returned from a function that does not explicitly return a value using the return keyword and it is the value that's returned from a statement (an action with no resulting value).

When working with undefined, you should always anticipate it, but never assign it to a variable or return it explicitly from a function. In such circumstances, you should use null.

Boolean Values

Boolean is a term named after George Boole, a nineteenth-century English mathematician and philosopher. It is used to denote the values true and false. These values may be assigned to variables and are strictly equivalent to their value, like null.

Booleans are unique among the types supported by JavaScript because they are indirectly comparable to other types and expressions. The logical operators described in Chapter 3, Programming Fundamentals, of this book, for instance, all result in a Boolean value.

主站蜘蛛池模板: 烟台市| 凉城县| 金溪县| 东源县| 扶绥县| 聂荣县| 夏津县| 新绛县| 南丹县| 万全县| 昭觉县| 龙岩市| 鲁甸县| 万荣县| 信宜市| 宕昌县| 紫金县| 高陵县| 日土县| 唐山市| 蒙山县| 昌都县| 理塘县| 恩施市| 凤庆县| 六盘水市| 满洲里市| 玉林市| 丹棱县| 萨迦县| 丹江口市| 上饶县| 武乡县| 阿克苏市| 广平县| 康乐县| 天全县| 五大连池市| 新密市| 仁化县| 驻马店市|