[ Leksykon ] [ JavaScript ] [ Metody ] [ String() ]
String concat()
[_] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] [Z]
Przykłady:
const tekstA = 'Przykładowy';
const tekstB = 'tekst.';
console.log(tekstA.concat(' ', tekstB));
// "Przykładowy tekst."
const tekstA = 'Przykładowy';
const tekstB = 'tekst.';
console.log(tekstA.concat(' ', tekstB, ' ', "Dodatkowy tekst."));
// "Przykładowy tekst."
const tekstA = ["Przykładowy", " ", "tekst", "."];
console.log("".concat(...tekstA)); // "Przykładowy tekst."
console.log("".concat(9, 1)); // "91"
console.log("".concat([])); // ""
console.log("".concat({})); // "[object Object]"
console.log("".concat(null)); // "null"
console.log("".concat(true)); // "true"
Opis:
Metoda concat() łączy łańcuchy tekstowe z ciągiem wywołującym i zwraca nowy ciąg.
Linki: