What data types does ECMAScript have?
ECMAScript data types are divided into two types: 1. Basic data types, including String, Number, Boolean, undefined, null and Symbol types; 2. Reference data types, including Object, Function and Array types.
The operating environment of this tutorial: Windows 7 system, ECMAScript version 6, Dell G3 computer.
ECMAScript data types can be divided into two types: basic data types and reference data types
Basic types
Basic types are also called value types.
String: Any string
Number: Any number
Boolean: true, false
## undefined: undefined
null: null
Symbol
##Object TypeObject type is also called reference type
- Object: any object
- Function: a special Object (difference from Object: can be executed)
- Array: a special object (numeric subscript, internal data is ordered)
How to determine the type of datatypeof: can determine undefined, numerical value, string, Boolean value, function
cannot determine : null and Object, Object and Array
Returns the string expression of the data type. instanceof: Determine the specific type of the object.
===: Can judge undefined and null
1. Basic type judgment method:
var a;
console.log(a);//undefined
console.log(typeof a);//"undefined"
console.log(a===undefined);//true
a=4;
console.log(typeof a==="number");//true
a='dewferf';
console.log(typeof a==='string');//true
console.log(typeof a==='String');//false
a=true;
console.log(typeof a === 'boolean');//true
a=null;
console.log(typeof a,a===null);//"object",true
var b1={
b2:[1,'avc',console.log],
b3:function(){
console.log('b3');
return function(){
return 'lxyxxx';
}
}
};
console.log(typeof b1.b2);//'object'
console.log(b1 instanceof Object,b1 instanceof Array);//true,false
console.log(b1.b2 instanceof Array,b1.b2 instanceof Object);//true,true
console.log(b1.b3 instanceof Function,b1.b3 instanceof Object);//true,true
console.log(typeof b1.b3);//'function'
console.log(typeof b1.b3 === 'function');//true
console.log(typeof b1.b2[2]);//'function'
console.log(typeof b1.b2[2] === 'function');//true
b1.b2[2](4);//因为b1.b2[2]是函数,所以会执行
b1.b3()();//
Symbol is a new data type introduced in ECMAScript6, which represents a unique value. Symbol type The value needs to be generated using the Symbol() function, as shown in the following example:
var str = "123"; var sym1 = Symbol(str); var sym2 = Symbol(str); console.log(sym1); // 输出 Symbol(123) console.log(sym2); // 输出 Symbol(123) console.log(sym1 == sym2); // 输出 false :虽然 sym1 与 sym2 看起来是相同的,但实际上它们并不一样,根据 Symbol 类型的特点,sym1 和 sym2 都是独一无二的
Since Symbol values are not objects, properties cannot be added. Basically, it is a string-like data type.javascript learning tutorial[Related recommendations:
The above is the detailed content of What data types does ECMAScript have?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The methods of the php8 data type include converting strings to integers, converting integers to strings, converting strings to floating point numbers, converting floating point numbers to strings, converting arrays to strings, converting strings to arrays, and converting Boolean values to integers. Integer conversion to Boolean value and variable type determination and conversion. Detailed introduction: 1. Converting a string to an integer includes the intval() function and (int) forced type conversion; 2. Converting an integer to a string includes the strval() function and (string) forced type conversion; 3. Converting a string to a float Points and so on.

In a MySQL database, gender fields can usually be stored using the ENUM type. ENUM is an enumeration type that allows us to select one as the value of a field from a set of predefined values. ENUM is a good choice when representing a fixed and limited option like gender. Let's look at a specific code example: Suppose we have a table called "users" that contains user information, including gender. Now we want to create a field for gender, we can design the table structure like this: CRE

In MySQL, the most suitable data type for gender fields is the ENUM enumeration type. The ENUM enumeration type is a data type that allows the definition of a set of possible values. The gender field is suitable for using the ENUM type because gender usually only has two values, namely male and female. Next, I will use specific code examples to show how to create a gender field in MySQL and use the ENUM enumeration type to store gender information. The following are the steps: First, create a table named users in MySQL, including

Python data types are: 1. Integer type; 2. Floating point type; 3. Complex number; 4. Boolean type; 5. String; 6. List; 7. Tuple; 8. Set; 9. Dictionary. Detailed introduction: 1. Integer type, used to represent integers, which can be positive, negative, or zero. In Python, the range of values that integers can represent is platform-specific; 2. Floating point type, used to represent numbers with decimal parts. Numbers, floating point type can represent positive numbers, negative numbers and zero; 3. Complex numbers, used to represent complex numbers, including real and imaginary parts; 4. Boolean type, used to represent Boolean values, etc.

Python is widely used in a wide range of fields with its simple and easy-to-read syntax. It is crucial to master the basic structure of Python syntax, both to improve programming efficiency and to gain a deep understanding of how the code works. To this end, this article provides a comprehensive mind map detailing various aspects of Python syntax. Variables and Data Types Variables are containers used to store data in Python. The mind map shows common Python data types, including integers, floating point numbers, strings, Boolean values, and lists. Each data type has its own characteristics and operation methods. Operators Operators are used to perform various operations on data types. The mind map covers the different operator types in Python, such as arithmetic operators, ratio

When designing database tables, choosing the appropriate data type is very important for performance optimization and data storage efficiency. In the MySQL database, there is really no so-called best choice for the data type to store the gender field, because the gender field generally only has two values: male or female. But for efficiency and space saving, we can choose a suitable data type to store the gender field. In MySQL, the most commonly used data type to store gender fields is the enumeration type. An enumeration type is a data type that can limit the value of a field to a limited set.

Detailed explanation of how to use Boolean types in MySQL MySQL is a commonly used relational database management system. In practical applications, it is often necessary to use Boolean types to represent logical true and false values. There are two representation methods of Boolean type in MySQL: TINYINT(1) and BOOL. This article will introduce in detail the use of Boolean types in MySQL, including the definition, assignment, query and modification of Boolean types, and explain it with specific code examples. 1. The Boolean type is defined in MySQL and can be

C language is a widely used computer programming language that is efficient, flexible and powerful. To be proficient in programming in C language, you first need to understand its basic syntax and data types. This article will introduce the basic syntax and data types of C language and give examples. 1. Basic syntax 1.1 Comments In C language, comments can be used to explain the code to facilitate understanding and maintenance. Comments can be divided into single-line comments and multi-line comments. //This is a single-line comment/*This is a multi-line comment*/1.2 Keyword C language
