บทความนี้อธิบายการใช้งานทั่วไปของอาร์เรย์ JS แบ่งปันสำหรับการอ้างอิงของคุณ วิธีการเฉพาะมีดังนี้:
คัดลอกรหัสดังนี้: <! Doctype html public "-// w3c // dtd xhtml 1.0 transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv = "content-type" content = "text /html; charset = utf-8" />
<title> แอปพลิเคชันของเมธอดอาร์เรย์ </title>
<script type = "text/javascript">
var arrayfruit = อาร์เรย์ใหม่ ("Apple", "Orange", "Peach", "Bannaner");
document.write ("อาร์เรย์ก่อนเรียงลำดับ <br/>");
สำหรับ (var i ใน arrayfruit) {
document.write (arrayfruit [i] + "<br />");
-
arrayfruit.sort (); // เรียงลำดับอาร์เรย์
document.write ("เรียงลำดับอาร์เรย์: <br />");
สำหรับ (var i ใน arrayfruit) {
document.write (arrayfruit [i] + "<br />");
-
document.write ("การเรียงลำดับสตริงที่เชื่อมต่อ: <br />");
var str = arrayfruit.oin ("-");
document.write (str);
var strfruit = "Apple, Bannaner, Orange, Peach";
var tempfruit = strfruit.split (",");
document.write ("อาร์เรย์หารด้วยสตริง <br />");
สำหรับ (var i ใน tempfruit) {
document.write (tempfruit [i] + "<br />");
-
</script>
</head>
<body>
</body>
</html>
ส่วนใหญ่จะแนะนำการเดินทางของอาร์เรย์และการแบ่งส่วนของสตริง เพื่อนที่สนใจสามารถทดสอบและเรียกใช้พวกเขา
ฉันหวังว่าบทความนี้จะเป็นประโยชน์กับการเขียนโปรแกรม JavaScript ของทุกคน