Hướng dẫn what are the primitive data types in javascript? - các kiểu dữ liệu nguyên thủy trong javascript là gì?

Kiểu dữ liệu: Mỗi biến có một loại dữ liệu cho biết loại dữ liệu nào đang được lưu trữ trong một biến. Có hai loại loại dữ liệu trong JavaScript là các loại dữ liệu nguyên thủy và các loại dữ liệu không nguyên thủy. Every Variable has a data type that tells what kind of data is being stored in a variable. There are two types of data types in JavaScript namely Primitive data types and Non-primitive data types.

Kiểu dữ liệu nguyên thủy: Các loại dữ liệu được xác định trước được cung cấp bởi ngôn ngữ JavaScript được gọi là các loại dữ liệu nguyên thủy. Các loại dữ liệu nguyên thủy còn được gọi là các loại dữ liệu được xây dựng.The predefined data types provided by JavaScript language are known as primitive data types. Primitive data types are also known as in-built data types.

Các loại dữ liệu không định tuyến: Các loại dữ liệu có nguồn gốc từ các loại dữ liệu nguyên thủy của ngôn ngữ JavaScript được gọi là các loại dữ liệu không nguyên thủy. Nó còn được gọi là các loại dữ liệu dẫn xuất hoặc các loại dữ liệu tham chiếu. The data types that are derived from primitive data types of the JavaScript language are known as non-primitive data types. It is also known as derived data types or reference data types.

Có năm loại loại dữ liệu nguyên thủy trong JavaScript.

1. Số: Kiểu dữ liệu số trong JavaScript có thể được sử dụng để giữ các giá trị thập phân cũng như các giá trị không có số thập phân.Number data type in javascript can be used to hold decimal values as well as values without decimals.

JavaScript

Hướng dẫn what are the primitive data types in javascript? - các kiểu dữ liệu nguyên thủy trong javascript là gì?

2.String: Kiểu dữ liệu chuỗi trong JavaScript thể hiện một chuỗi các ký tự được bao quanh bởi các trích dẫn đơn hoặc đôi.

    

// An empty object
var square = {};

// Here a and b are keys and
// 20 and 30 are values
var circle = {a: 20, b: 30};
9
// Call it with no arguments
var a = new Array();

// Call it with single numeric argument
var b = new Array(10);

// Explicitly specify two or
// more array elements
var d = new Array(1, 2, 3, "Hello");
0
// Call it with no arguments
var a = new Array();

// Call it with single numeric argument
var b = new Array(10);

// Explicitly specify two or
// more array elements
var d = new Array(1, 2, 3, "Hello");
1
The meaning of undefined is ‘value is not assigned’.

JavaScript

// An empty object
var square = {};

// Here a and b are keys and
// 20 and 30 are values
var circle = {a: 20, b: 30};
6


Hướng dẫn what are the primitive data types in javascript? - các kiểu dữ liệu nguyên thủy trong javascript là gì?

    console.log(

// An empty object
var square = {};

// Here a and b are keys and
// 20 and 30 are values
var circle = {a: 20, b: 30};
4
// An empty object
var square = {};

// Here a and b are keys and
// 20 and 30 are values
var circle = {a: 20, b: 30};
5

đầu ra số

2.String: Kiểu dữ liệu chuỗi trong JavaScript thể hiện một chuỗi các ký tự được bao quanh bởi các trích dẫn đơn hoặc đôi.Object in Javascript is an entity having properties and methods. Everything is an object in javascript.

    

// An empty object
var square = {};

// Here a and b are keys and
// 20 and 30 are values
var circle = {a: 20, b: 30};
9
// Call it with no arguments
var a = new Array();

// Call it with single numeric argument
var b = new Array(10);

// Explicitly specify two or
// more array elements
var d = new Array(1, 2, 3, "Hello");
0
// Call it with no arguments
var a = new Array();

// Call it with single numeric argument
var b = new Array(10);

// Explicitly specify two or
// more array elements
var d = new Array(1, 2, 3, "Hello");
1

  •     console.log(
    // Call it with no arguments
    var a = new Array();
    
    // Call it with single numeric argument
    var b = new Array(10);
    
    // Explicitly specify two or
    // more array elements
    var d = new Array(1, 2, 3, "Hello");
    8
    // Call it with no arguments
    var a = new Array();
    
    // Call it with single numeric argument
    var b = new Array(10);
    
    // Explicitly specify two or
    // more array elements
    var d = new Array(1, 2, 3, "Hello");
    9
// Create an empty generic object
var obj = new Object();

// Create a user defined object
var mycar = new Car();