v2.5.2
Giriş yap

Javascript concat() Metodu

ES1

İki ve ya daha fazla diziyi birleştirmek için kullanılır.
Bu metod, varolan diziyi değiştirmez. Birleştirilmiş yeni bir dizi döndürür.

Yapısı (Syntax)array1.concat(array2, array3, ..., arrayX)

Parametreler

  • array2, array3, ..., arrayX
    ( ! ) Notice: Undefined property: stdClass::$type in /home/prototurk.com/public_html/app/view/article-js.php on line 64
    Call Stack
    #TimeMemoryFunctionLocation
    10.0001360288{main}( ).../index.php:0
    20.0037444456require( '/home/prototurk.com/public_html/app/controller/category.php' ).../index.php:101
    30.0060456088require( '/home/prototurk.com/public_html/app/view/article.php' ).../category.php:34
    40.0116536080parseTemplate( ).../article.php:112
    50.0116536192preg_replace_callback ( ).../template.php:126
    60.0116536712bb_json( ).../template.php:126
    70.0118562648require( '/home/prototurk.com/public_html/app/view/article-js.php' ).../template.php:220
    Birleştirilecek diziler

Dönen Değer

Birleştirilmiş dizi objesini döndürür.

Örnekler

İki dizinin birleştirilmesi

Aşağıdaki kod, iki diziyi birleştirir.

const letters = ['a', 'b', 'c'];
const numbers = [1, 2, 3];

const newArray = letters.concat(numbers);
console.log(newArray);

// Çıktı: ['a', 'b', 'c', 1, 2, 3]

Örneği Dene »

Üç dizinin birleştirilmesi

Aşağıdaki kod, üç diziyi birleştirir. Bu şekilde 2 veya daha fazla diziyi birleştirebilirsiniz.

const num1 = [1, 2, 3];
const num2 = [4, 5, 6];
const num3 = [7, 8, 9];

const numbers = num1.concat(num2, num3);
console.log(numbers); 

// Çıktı: [1, 2, 3, 4, 5, 6, 7, 8, 9]

Örneği Dene »

Değerleri diziye birleştirme

Metod parametre olarak sadece dizi değil bir değerde alabilir. Aşağıdaki kod, bir değer ve dizilerin birleşimini gösterir.

const array1 = ['a', 'b', 'c'];

const newArray = array1.concat('d', ['e', 'f']);
console.log(newArray);

// Çıktı: ["a", "b", "c", "d", "e", "f"]

Örneği Dene »

İç içe dizileri birleştirme

Aşağıdaki kod, iç içe dizileri birleştirmeye ve referansların korunmasına örnektir.

const num1 = [[1]];
const num2 = [2, [3]];

const numbers = num1.concat(num2);

console.log(numbers);
// Çıktı: [[1], 2, [3]]

// num1 dizisinin ilk elemanına yeni bir değer ekle
num1[0].push(4);

console.log(numbers);
// Çıktı: [[1, 4], 2, [3]]

Örneği Dene »

tayfunerbilen
1252 gün önce eklendi - 7883 kez görüntülendi.
Github'da Düzenle
Önceki JavaScript / Javascript ile Türkçe Harfleri Büyük/Küçük Yapmak Sonraki every()