init at work
This commit is contained in:
Executable
+28
@@ -0,0 +1,28 @@
|
||||
# Template Literals
|
||||
|
||||
Template literals are strings enclosed by backticks and support interpolation.
|
||||
|
||||
## Syntax
|
||||
|
||||
```ts
|
||||
const year = '2026';
|
||||
const month = '03';
|
||||
const day = '24';
|
||||
|
||||
const label = `${year}-${month}-${day}`;
|
||||
console.log(label); // '2026-03-24'
|
||||
```
|
||||
|
||||
## Why use them
|
||||
|
||||
- Easier than concatenation.
|
||||
- More readable for multi-part strings.
|
||||
- Supports multiline text.
|
||||
|
||||
## Python Comparison
|
||||
|
||||
Equivalent concept to Python f-strings:
|
||||
|
||||
```py
|
||||
label = f"{year}-{month}-{day}"
|
||||
```
|
||||
Reference in New Issue
Block a user