تستخدم المصفوفات في تسهيل البرمجه
مثلا متغير1 و متغير2 و متغير3 يكون بعد تحويل الي مصفوفه متغير و رقم المصفوفه
عمليه التحويل
var txt=new Array();
txt[0]="gotofon";
txt[1]="google";
txt[2]="yahoo";
او
var txt=new Array("gotofon","google","yahoo");
او
var txt=["gotofon","google","yahoo"];
اذا كنت تريد تغير txt[2]=yahoo الي maktoob
txt[2]="maktoob";
عمليه الاستخراج
<script type="text/javascript">
document.write( txt[0] );
document.write( txt[1] );
document.write( txt[2] );
</script>
او
<script type="text/javascript">
for (x in txt)
{
document.write(txt[x] + " ");
}
</script>
ليست هناك تعليقات:
إرسال تعليق