JavaScript Dizileri Birleştirme

S

Shiva

Veteran
Joined
Jul 31, 2019
Messages
4,067
Reaction score
13,319
Location
Berlin
İki diziyi birleştirmek için diziye metotları içinden concat metodu kullanılır. Concat metodu ile iki diziyi birleştirmek mümkündür. Aşağıdaki iki ayrı şehir dizisini birleştirip şehirler dizisine aktarımı gösterilmektedir.


JavaScript dizi birleştirme örneği:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Algoritmaornekleri.com</title>
</head>
<body>

<h2 id="mesaj"></h2>
<script>
var sehir1 = ["İstanbul", "Ankara", "Anakra"];
var sehir2 = ["Edirne", "Çanakkale", "Konya", "Yozgat"];
var tumSehirler = sehir2.concat(sehir1);
document.getElementById("mesaj").innerHTML = tumSehirler;
</script>
</body>
</html>
 
SPAM IS FORBIDDEN!
  • SPAMMERS ARE BANNED FROM THE FORUM AND CANNOT USE ANY OF THE CHEATS
  • For example: thanks, thx, very good, asdqwe, working, ty and so on!
  • For example: Writing the same message over and over. thanks, thx and so on!
  • Copying and copying someone else's message is prohibited.
  • It is forbidden to send messages to increase the number of comments on threads that you have no knowledge of.
  • Write your own opinion when commenting!
  • If you see spam message, please let us know with the REPORT button!

Tema düzenleyici

Top Bottom