种生基是什么意思| 头晕头疼是什么原因| 自主神经功能紊乱吃什么药| 周杰伦英文名叫什么| 世界上什么最大| 右下腹疼痛挂什么科| 痛风什么东西不可以吃| 今天冬至吃什么| 米酒不甜是什么原因| 吖什么意思| 梦到钓鱼是什么征兆| 救赎是什么意思| msv是什么单位| 世界上最难的数学题是什么| 尿白细胞阳性什么意思| 春代表什么生肖| 牙周康又叫什么名字| 藕粉色是什么颜色| 老年人吃什么增强免疫力| 为什么叫马桶| th什么意思| 黑色碳素笔是什么笔| 生化是检查什么的| 广州有什么好吃的| 出油多是什么原因| 为什么出汗特别多| 疏肝解郁喝什么茶| 黔驴技穷是什么意思| 8月是什么季节| 黄芪是什么样子的| 结肠憩室是什么意思| 咽喉有异物感吃什么药| 社保卡是什么样的图片| 豪爽是什么意思| 丹参与什么搭配最好| ace是什么意思| 新生儿晚上哭闹不睡觉是什么原因| 瑞舒伐他汀钙片治什么病| 特警属于什么编制| 可颂是什么意思| 寒战是什么症状| 陛下的陛是什么意思| 男性支原体感染什么症状| 脸上有痣去医院挂什么科| 红豆大红豆芋头是什么歌| 掉头发是因为什么| 子衿什么意思| 百花齐放是什么生肖| std什么意思| 卫生棉条是什么| 外阴皮肤痒是什么原因| 外阴红肿瘙痒用什么药| lv是什么意思| 射手是什么星象| 九点到十点是什么时辰| 头发长得快是什么原因| 弯弯的彩虹像什么| 刷牙出血是什么原因| 小腹痛是什么原因| 姨妈不正常是什么原因| 快乐的反义词是什么| 吃榴莲不能和什么一起吃| 纠察是什么意思| 唇炎是什么原因引起的| 什么是穿刺| 吃什么会引起尿酸高| 纳囊是什么病| 睡眠障碍挂什么科| 女人人中深代表什么| bg什么意思| txt什么意思| 长期喝什么水可以美白| 贡生相当于现在的什么| 梦见皮带断了什么预兆| 野兔子吃什么| 姜黄与生姜有什么区别| 白带发黄粘稠是什么原因| 塔罗是什么意思| 焦虑失眠吃什么药最好| 飞蛾为什么会扑火| 送女朋友什么礼物| leu是什么氨基酸| 医院总务科是干什么的| 甲功五项查的是什么| 梦到前妻预示什么| 连续放屁是什么原因呢| 跑龙套是什么意思| 五指姑娘是什么意思| 高危hpv有什么症状| 汤圆和元宵有什么区别| 回族不吃什么肉| 一日三餐是什么意思| 皮肤长小肉粒是什么原因| 水平是什么意思| 淼怎么读什么意思| 马桶为什么叫马桶| 磁共振和ct有什么区别| 煲仔饭用什么米最好| 细软是什么意思| 姑息性化疗什么意思| 绿色属于五行属什么| 梦见捡菌子是什么预兆| 外地车进北京有什么限制| 蔡英文是什么党派| 抖m是什么| 答谢宴是什么意思| 急性扁桃体化脓是什么原因引起的| 痛风反复发作什么原因| 抽筋缺什么维生素| 女人眼睛干涩吃什么药| 对牛弹琴告诉我们什么道理| 房中术是什么意思| 左肾小结石是什么意思| 肯定是什么意思| 男生适合养什么小型犬| 下雨为什么会打雷闪电| 3月7日是什么星座| 明前茶什么意思| 小炒皇是什么菜| gpt是什么意思| 维生素d是什么东西| 子宫腺肌症吃什么药| 一阴一阳是什么生肖| 两肺纹理增粗是什么意思| 827是什么意思| 什么的散步| rt是什么| 虬结什么意思| hpv病毒通过什么途径传播| 血液属于什么组织| 层出不穷是什么意思| 甲虫吃什么| 什么的孩子| 前列腺炎用什么药| 伤寒是什么意思| icu和ccu有什么区别| 古惑仔为什么不拍了| 逸五行属性是什么| 相手蟹吃什么| 眼震是什么症状| 世界上什么动物牙齿最多| 痨病是什么病| 2014属什么生肖| 手脚出汗多是什么原因| 嘴里发酸是什么原因| 中国最厉害的武器是什么| 大地鱼是什么鱼| 税号是什么| 散光轴位是什么意思| 为什么咳嗽| 小便发黄是什么原因| 承你吉言是什么意思| 火车上不能带什么| 养字五行属什么| 玄牝是什么意思| hcv是什么病| 蛋白质阴性是什么意思| 济公是什么生肖| 三高人群适合吃什么水果| 痛风吃什么菜好| 什么是神经衰弱| 日成念什么| 为什么怀孕这么难| 半夜会醒是什么原因| 吃什么长头发又密又多| 边长是什么| 10月1日是什么日子| 11月什么星座| 蝴蝶效应比喻什么| 鸽子补什么| 端午节吃什么食物| 母猫怀孕有什么症状| 梦见皮带断了什么预兆| 压到蛇了是有什么预兆| 眉心长痘是什么原因| 呀啦嗦是什么意思| 牙胶是什么| 什么食物是养肝的| 萨德事件是什么意思| 睡觉磨牙齿是什么原因| 精囊腺囊肿是什么意思| hpc是什么意思| 十年粤语版叫什么名字| 洛神是什么意思| 晕车是什么原因| 后脑勺白头发多是什么原因| 3楼五行属什么| 摩尔是什么| mlf操作是什么意思| 痔疮不能吃什么食物| 大众什么车最贵| 附件炎吃什么药| 本色出演是什么意思| 寸是什么单位| 老年人晚上夜尿多是什么原因| 玄牝是什么意思| 工匠精神的核心是什么| 腰椎疼痛是什么原因| 高筋面粉和低筋面粉有什么区别| 黄鱼是什么鱼| 没有奶水怎么办吃什么能下奶| 双侧甲状腺弥漫病变是什么意思| nnd什么意思| 给孕妇送什么礼物好| 什么是动物奶油| xswl是什么意思| 仓鼠怀孕有什么特征| b是什么牌子| 姨妈期吃什么水果| 易烊千玺原名叫什么| cy什么意思| 医院康复科是干什么的| vb是什么意思| 伤口愈合慢是什么原因| 女生适合做什么工作| 中年人喝什么奶粉好| 咽喉肿痛吃什么药| 美商是什么意思| 肠道紊乱吃什么药| 什么样的鼻子| 流加金念什么| 老鼠和什么属相最配对| 阴虱用什么药治疗| 胆红素偏高是什么意思| 肚子痛吃什么药好| 为什么狱警离婚率高| 2004年是什么生肖| 脚底有黑痣有什么说法| cmn是什么意思| 过敏能吃什么| 白癜风是什么原因引起的| 九五年属什么生肖| 热浪是什么意思| 用什么梳子梳头发最好| 油性头发用什么洗发水| 俞字五行属什么| 海洋里面有什么动物| 后背一推就出痧是什么原因| 化妆水是干什么用的| 鹌鹑吃什么| 巴特是什么意思| 嘴唇发紫什么原因| 女人梦见搬家预示什么| 脑血管堵塞吃什么药好| 易烊千玺是什么星座| 什么鱼刺少好吃| 大千世界什么意思| 100001是什么电话| 冬天怕冷夏天怕热是什么体质| 7.1是什么星座| 双性是什么意思| 解脲支原体阳性吃什么药最好| 余事勿取 什么意思| 小腹左侧疼是什么原因| 眼角痒用什么眼药水好| 眉梢有痣代表什么| 阑尾炎吃什么药效果好| 21三体高风险是什么意思| 孕妇睡觉流口水是什么原因| 什么牌子的燃气灶质量好| michaelkors是什么牌子| 梦见小狗是什么意思| 办幼儿园需要什么证| 什么原因引起脑梗| 百度
JAVASCRIPT BASIC
JAVASCRIPT & DOM
JAVASCRIPT & BOM
JAVASCRIPT ADVANCED
JAVASCRIPT EXAMPLES
JAVASCRIPT REFERENCE

泉州最好吃的肉燕汤,竟藏在巷口的这家10年老店

百度 欧委会称,由于税收体制原因,很多由互联网用户发挥主要作用、实现价值创造的业务目前无法足额纳税。

In this tutorial you will learn about the data types available in JavaScript.

Data Types in JavaScript

Data types basically specify what kind of data can be stored and manipulated within a program.

There are six basic data types in JavaScript which can be divided into three main categories: primitive (or primary), composite (or reference), and special data types. String, Number, and Boolean are primitive data types. Object, Array, and Function (which are all types of objects) are composite data types. Whereas Undefined and Null are special data types.

Primitive data types can hold only one value at a time, whereas composite data types can hold collections of values and more complex entities. Let's discuss each one of them in detail.

The String Data Type

The string data type is used to represent textual data (i.e. sequences of characters). Strings are created using single or double quotes surrounding one or more characters, as shown below:

let a = 'Hi there!';  // using single quotes
let b = "Hi there!";  // using double quotes

You can include quotes inside the string as long as they don't match the enclosing quotes.

let a = "Let's have a cup of coffee."; // single quote inside double quotes
let b = 'He said "Hello" and left.';  // double quotes inside single quotes
let c = 'We\'ll never give up.';     // escaping single quote with backslash

You will learn more about the strings in JavaScript strings chapter.


The Number Data Type

The number data type is used to represent positive or negative numbers with or without decimal place, or numbers written using exponential notation e.g. 1.5e-4 (equivalent to 1.5x10-4).

let a = 25;         // integer
let b = 80.5;       // floating-point number
let c = 4.25e+6;    // exponential notation, same as 4.25e6 or 4250000
let d = 4.25e-6;    // exponential notation, same as 0.00000425

The Number data type also includes some special values which are: Infinity, -Infinity and NaN. Infinity represents the mathematical Infinity , which is greater than any number. Infinity is the result of dividing a nonzero number by 0, as demonstrated below:

alert(16 / 0);  // Output: Infinity
alert(-16 / 0); // Output: -Infinity
alert(16 / -0); // Output: -Infinity

While NaN represents a special Not-a-Number value. It is a result of an invalid or an undefined mathematical operation, like taking the square root of -1 or dividing 0 by 0, etc.

alert("Some text" / 2);       // Output: NaN
alert("Some text" / 2 + 10);  // Output: NaN
alert(Math.sqrt(-1));         // Output: NaN

You will learn more about the numbers in JavaScript numbers chapter.


The Boolean Data Type

The Boolean data type can hold only two values: true or false. It is typically used to store values like yes (true) or no (false), on (true) or off (false), etc. as demonstrated below:

let isReading = true;   // yes, I'm reading
let isSleeping = false; // no, I'm not sleeping

Boolean values also come as a result of comparisons in a program. The following example compares two variables and shows the result in an alert dialog box:

let a = 2, b = 5, c = 10;
 
alert(b > a) // Output: true
alert(b > c) // Output: false

You will learn more about the comparisons in JavaScript if/else chapter.


The Undefined Data Type

The undefined data type can only have one value-the special value undefined. If a variable has been declared, but has not been assigned a value, has the value undefined.

let a;
let b = "Hello World!";
 
alert(a) // Output: undefined
alert(b) // Output: Hello World!

The Null Data Type

This is another special data type that can have only one value-the null value. A null value means that there is no value. It is not equivalent to an empty string ("") or 0, it is simply nothing.

A variable can be explicitly emptied of its current contents by assigning it the null value.

let a = null;
alert(a); // Output: null
 
let b = "Hello World!";
alert(b); // Output: Hello World!
 
b = null;
alert(b) // Output: null

The Object Data Type

The object is a complex data type that allows you to store collections of data.

An object contains properties, defined as a key-value pair. A property key (name) is always a string, but the value can be any data type, like strings, numbers, booleans, or complex data types like arrays, function and other objects. You'll learn more about objects in upcoming chapters.

The following example will show you the simplest way to create an object in JavaScript.

let emptyObject = {};
let person = {"name": "Clark", "surname": "Kent", "age": "36"};
 
// For better reading
let car = {
    "modal": "BMW X3",
    "color": "white",
    "doors": 5
}

You can omit the quotes around property name if the name is a valid JavaScript name. That means quotes are required around "first-name" but are optional around firstname. So the car object in the above example can also be written as:

let car = {
    modal: "BMW X3",
    color: "white",
    doors: 5
}

You will learn more about the objects in JavaScript objects chapter.


The Array Data Type

An array is a type of object used for storing multiple values in single variable. Each value (also called an element) in an array has a numeric position, known as its index, and it may contain data of any data type-numbers, strings, booleans, functions, objects, and even other arrays. The array index starts from 0, so that the first array element is arr[0] not arr[1].

The simplest way to create an array is by specifying the array elements as a comma-separated list enclosed by square brackets, as shown in the example below:

let colors = ["Red", "Yellow", "Green", "Orange"];
let cities = ["London", "Paris", "New York"];
 
alert(colors[0]);   // Output: Red
alert(cities[2]);   // Output: New York

You will learn more about the arrays in JavaScript arrays chapter.


The Function Data Type

The function is callable object that executes a block of code. Since functions are objects, so it is possible to assign them to variables, as shown in the example below:

let greeting = function(){ 
    return "Hello World!"; 
}
 
// Check the type of greeting variable
alert(typeof greeting) // Output: function
alert(greeting());     // Output: Hello World!

In fact, functions can be used at any place any other value can be used. Functions can be stored in variables, objects, and arrays. Functions can be passed as arguments to other functions, and functions can be returned from functions. Consider the following function:

function createGreeting(name){
    return "Hello, " + name;
}
function displayGreeting(greetingFunction, userName){
    return greetingFunction(userName);
}
 
let result = displayGreeting(createGreeting, "Peter");
alert(result); // Output: Hello, Peter

You will learn more about the functions in JavaScript functions chapter.


The typeof Operator

The typeof operator can be used to find out what type of data a variable or operand contains. It can be used with or without parentheses (typeof(x) or typeof x).

The typeof operator is particularly useful in the situations when you need to process the values of different types differently, but you need to be very careful, because it may produce unexpected result in some cases, as demonstrated in the following example:

// Numbers
typeof 15;  // Returns: "number"
typeof 42.7;  // Returns: "number"
typeof 2.5e-4;  // Returns: "number"
typeof Infinity;  // Returns: "number"
typeof NaN;  // Returns: "number". Despite being "Not-A-Number"
 
// Strings
typeof '';  // Returns: "string"
typeof 'hello';  // Returns: "string"
typeof '12';  // Returns: "string". Number within quotes is typeof string
 
// Booleans
typeof true;  // Returns: "boolean"
typeof false;  // Returns: "boolean"
 
// Undefined
typeof undefined;  // Returns: "undefined"
typeof undeclaredVariable; // Returns: "undefined"
 
// Null
typeof Null;  // Returns: "object"
 
// Objects
typeof {name: "John", age: 18};  // Returns: "object"
 
// Arrays
typeof [1, 2, 4];  // Returns: "object"
 
// Functions
typeof function(){};  // Returns: "function"

As you can clearly see in the above example when we test the null value using the typeof operator (line no-22), it returned "object" instead of "null".

This is a long-standing bug in JavaScript, but since lots of codes on the web written around this behavior, and thus fixing it would create a lot more problem, so idea of fixing this issue was rejected by the committee that design and maintains JavaScript.

Bootstrap UI Design Templates Property Marvels - A Leading Real Estate Portal for Premium Properties
锦衣卫是干什么的 糖类抗原是什么 前囟门什么时候闭合 河北有什么山 角膜塑形镜什么牌子好
人乳头瘤病毒16型阳性是什么意思 夏侯霸为什么投降蜀国 高考移民是什么意思 什么是冰丝面料 区域经理的岗位职责是什么
吃什么对胰腺好 s是什么车 为什么身上会长脂肪瘤 sec是什么单位 氢化油是什么东西
十二生肖排第七是什么生肖 中药龙骨是什么 血虚吃什么药 吃百合有什么好处 法西斯是什么
得了甲亢都有什么症状hcv8jop2ns3r.cn 可定什么时间服用最好hcv9jop3ns6r.cn 右侧胸膜增厚是什么意思hcv8jop2ns4r.cn 关节疼挂什么科hcv8jop2ns7r.cn 杞人忧天告诉我们什么道理hcv8jop9ns5r.cn
哺乳期可以吃什么消炎药hcv8jop3ns0r.cn 微生物是什么creativexi.com 破伤风有什么症状hcv9jop7ns4r.cn 血糖高早餐吃什么hcv9jop6ns2r.cn 一丝不苟是什么生肖hcv7jop6ns7r.cn
打玻尿酸有什么危害hcv8jop3ns1r.cn n t是什么检查hcv9jop6ns4r.cn 岔气是什么症状bfb118.com 经常放屁吃什么药好hcv9jop0ns8r.cn 梦见自己有孩子了是什么预兆tiangongnft.com
牛肉不能和什么水果一起吃hcv9jop2ns2r.cn 醋泡什么壮阳最快hcv8jop8ns3r.cn 墙头是什么意思hcv8jop2ns0r.cn 检查阑尾炎挂什么科hcv7jop5ns5r.cn 蛇年五行属什么hcv8jop6ns6r.cn
百度