ยินดีต้อนรับสู่เว็ปไซต์ดิจิตอล JAVASCRIPT

การสร้าง Array แบบกำหนดค่าทันที


ทำได้โดยใส่ค่าลงไปใน Array ตั้งแต่ตอนประกาศเลย เราเรียก array ที่ประกาศด้วยวิธีนี้ว่า dense array เช่น

DayOfWeek = new Array('Sun','Mon','Tue','Wed','Thu','Fri','Sat')

การใช้ Array หลายมิติ

JavaScript ไม่ได้จำกัดว่าข้อมูลใน Array จะต้องเป็นชนิดเดียวกัน มันอาจเป็น ข้อมูลต่างชนิดกันก็ได้ และจะเป็น Array ก็ได้

ครับ ถ้ามี Array อยูใน Array เป็น Array ซ้อน Array เช่น เวลาอ้างถึง  ทำได้ดังนี้

<HTML>

<HEAD>

<TITLE>Arrays within Arrays</TITLE>

</HEAD>

<BODY>

<H1 ALIGN="CENTER">Arrays within Arrays</H1>

<SCRIPT LANGUAGE="JavaScript"><!--

junk = new Array("s1",'s2',4,3.5,true,false,null,new Array(5,6,7));

document.write("junk[0] = "+junk[0]+"<BR>");

document.write("junk[1] = "+junk[1]+"<BR>");

document.write("junk[2] = "+junk[2]+"<BR>");

document.write("junk[3] = "+junk[3]+"<BR>");

document.write("junk[4] = "+junk[4]+"<BR>");

document.write("junk[5] = "+junk[5]+"<BR>");

document.write("junk[6] = "+junk[6]+"<BR>");

document.write("junk[7][0] = "+junk[7][0]+"<BR>");

document.write("junk[7][1] = "+junk[7][1]+"<BR>");

document.write("junk[7][2] = "+junk[7][2]);

// -->

</SCRIPT>

</BODY>

</HTML>

 

 

 

 

 

JavaScript
JavaScript คืออะไร
ลักษณะการทำงานของ JavaScript
การทำงานร่วมกับ HTML
การเขียนโปรแกรมจาวาสคริปต์
รูปแบบของจาวาสคริปต์
การทำ Include ไฟล์
การใส่ Comment ใน JavaScript
ตัวแปร
การตั้งชื่อตัวแปร
ชนิดของตัวแแปร
ตัวแปรชนิดตัวเลข
Float
ตัวแปรชนิดตรรก
ตัวแปรชนิดข้อความ
สัญลักษณ์พิเศษ
ตัวแปรว่างเปล่า
ตารางผสมตัวแปรต่างชนิด
Array
Array คืออะไร
การสร้าง Array แบบกำหนดค่าทันที
Statement
Statement คืออะไร
If...else
for
While
Do..While
สัญลักษณ์ที่ใช้ในการเปรียบเทียบ
Function
Function คืออะไร
Date Methods
Math Properties / Methods
คำสงวน
คำสงวนของภาษา JavaScript
ตัวอย่าง
ตัวอย่าง Javascript
ผู้จัดทำ
สมาชิกในกลุ่มและจุดประสงค์ของงาน
แหล่งอ้างอิง
เว็ปไซต์ที่อ้างอิง
แบบทดสอบ
แบบทดสอบชุดที่ 1