شرح صفوف ومحتوى الفقرة
هناك طريقتين لطباعة الكائنات Objects في لغة الجافا سكريبت :
- الطريقة الاولي Dot notation : وهي الطريقة الشائعة عن طريق كتابة متغير ال object ثم نتبعه بمفتاح الخاصية property key
- الطريقة الثانية Bracket notation : وهي عن طريق الاقواس المربعة square brackets [ ]
الطريقة الاولي dot notation
HTML
var plane = {type:"MS", model:2001, color:"white"};
document.write("The Plane Color is " + plane.color);
document.write("The Plane model is " + plane.model);
الطريقة الثانية Bracket notation
HTML
var plane= {type:"MS", model:2001, color:"white"};
document.write("The Plane Color is " + plane['color']);
document.write("The Plane model is " + plane['model']);