Skip to content

字符串

一句话解释

字符串是 序列的 characters — 文本 — enclosed in quotes, 如 "hello" or "Ada Lovelace".

用大白话说

string 是how programming languages represent text。 It is an ordered sequence of characters — letters, digits, spaces, punctuation, even emoji — wrapped in quotes so the computer knows it is text and not code.

你可以create strings with single quotes ('hi'), double quotes ("hi"), or backticks (\hi\`) in JavaScript. Strings can be joined (concatenated), split, searched, and transformed with methods like toUpperCase() or slice()`.

Strings are everywhere: user input from forms, file paths, error messages, JSON data. Almost every program you write will work with strings in some way.

示例

javascript
let greeting = "Hello, ";
let name = "Ada";

console.log(greeting + name);        // "Hello, Ada"
console.log(name.toUpperCase());     // "ADA"
console.log(name.length);           // 3

字符串 能 是 concatenated 使用 +, transformed 使用 方法 如 toUpperCase(), and inspected 使用 .长度.

相关术语

相关资源

相关课程

相关工具

解读错误信息

用大白话解释常见错误——什么意思、为什么发生、如何修复。

查看错误

← 返回术语表