ECMAScript Data Structures Analysis

In ECMAScript, the following data types exist:

  1. Primitive data types:
    • Boolean: true and false
    • Number: Integers and floating-point numbers
    • String: A sequence of characters
    • Null: Represents an empty object pointer
    • Undefined: Represents an uninitialized variable
  2. Reference data types:
    • Object: A collection of properties, where each property is a key-value pair
    • Array: A collection of values arranged in order, accessible via numeric indices
    • Function: A reusable block of code that can accept parameters and return values
    • Date: Represents time and date values
    • RegExp: An object used for matching string patterns
    • Other reference types such as Map, Set, and Promise, which were introduced in newer versions of ECMAScript.

In ECMAScript, the data type of a variable is dynamic, meaning that a variable can change its data type at runtime. For example, a variable might hold a number at one moment and a string at another. This flexibility is an important feature of ECMAScript, making it very useful for writing dynamic web applications.

String

Declaring String Variables

String variables can be declared using double quotes (") or single quotes (').

let string = "hello";
let string2 = 'world';

Template Literals

The ${} syntax is used to declare string templates.

let number = 1;
let stringTemplate = `abc${number}`;
console.log(stringTemplate);
// Output result: abc1