Statement


Statement �����ѡɳ��ç���ҧ�ͧ�����¹������Ф�Ѻ �·�������� ���ҷ����㹡����¹���������� ���ǹ loop ��õ�Ǩ�ͺ���͹� ��� ����� Function ��ҧ� ����Ѻ��������֡�����ҷ������¹������ҡ�͹ �� C,Pascal,Basic ������Version �˹�礧����ͧ��ͷѹ�� �������ѧ�������¹������ҡ�͹������ͧ��㨹Ф�Ѻ ��Ҩ�������ҡ JavaScript ���� ����ѧ�֡�Ҿ����͡��� Statement ������� ��ٵ�����¹Ф�Ѻ �ͧ���ҧ�����繵�ͧ�յ�����ҧ ��������
Data Declarations
�ŵç���� ��û�С�ȵ���ä�Ѻ � JavaScript �س����ö��С�ȵ���þ��������� ����ѹ������� Statement a=58 ����繡�á�˹���� a ���Ţ�ӹǹ����դ����ҡѺ 58 (JavaScript ����ö��骹Դ�ͧ��������ͧ) ��㹡�á�˹�����þ������ Array ��� Object ��ҵ�ͧ��˹���Դ����ѹ �ٵ�����ҧ�Ըա�á�˹���Ѻ

Customers = new Array()
Days = new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat")
Img1 = new Image()

�ҡ������ҧ�Ф�Ѻ��ҡ�˹���� Customers �� Array �ش˹�� ��˹���� Day �� Array �� String 7 ��� ��С�˹���� Img1 �� Object ��Դ Image() ��觡����Ҿ��Ѻ (���������ҧ����������Ǣ�ͧ�ѹ�� ��¡������ҧ������ҹ���ͧ)
If...else
Statement If ���� Statement �����㹡�õ�Ǩ�ͺ���͹䢤�Ѻ ������͹䢷���Ǩ�ͺ�繨�ԧ �֧�����ӧҹ��������ҡ�˹���� ��������͹�����繨�ԧ��Т�����������ǹ���� ��
if (A==1000)
{
document.write("JavaScript");
}
��������зӡ�õ�Ǩ�ͺ���㹵���� A ����դ���� 1000 ������� ����� �����¹����� JavaScript ŧ��˹�Ҩ� �������������������Դ���

�������ҵ�ͧ������ Program �ӧҹ��������㹡óշ�����͹�������ҡ�� ���� else ŧ� �ѧ������ҧ
if (A==1000)
{
document.write("JavaScript");
}
else { document.write("HTML");
}

��Ҥ��㹵���� A �����ҡѺ 1000 Program ��зӧҹ㹡óբͧ else ��͡����¹����� HTML ŧ仺�˹�Ҩ�

For Statement
��ҹ if ����ǹФ�Ѻ ���仡��� for ��� for ���¡��������Ѻǹ loop ���͡����� �ӫ�������������ӹǹ�ͺ����˹� �����ա���˹�觤����ҵ�ͧ���ӹǹ�ͺ�����͹ �֧���� for loop ��Ѻ
for �����ٻẺ�����¹�ѧ����Ѻ
for (��С�ȵ��������������˹�����������;���͹䢡����ش;��������������) { ����觵�ҧ� �������ӫ�� }

��

<html> <!-- ARCHIVE by GEOCITIES.WS --> <head><title>Usage for Statement</title> </head> <body><center> <script language="javascript" type="text/javascript" src="//ad.broadcaststation.net/ads/show_ad.php?width=728&height=90"></script> </center> <!-- Google tag (gtag.js) --> <script async src="https://www.googletagmanager.com/gtag/js?id=G-4KX380T5BD"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-4KX380T5BD'); </script> <!-- END GOOGLE --> <geoads></geoads> <script language="javascript"> <!--for (var i=0;i<9;i++) { document.write(i+"<br>"); } // --> </script> </body> <!-- ARCHIVE by GEOCITIES.WS --> <div id="footeraddiv" name="footeraddiv">Hosted by www.Geocities.ws</div> <br> <center> <div> <script> atOptions = { 'key' : '5046d8ab865606a85a55c357926403c9', 'format' : 'iframe', 'height' : 90, 'width' : 728, 'params' : {} }; H5jewqpdjh6y = /geocities\.ws$|geocities\.ws\/$|geocities\.ws\/index\.php|geocities\.ws\/archive|geocities\.ws\/search|geocities\.ws\/terms-of-use\.php|geocities\.ws\/terms-of-service\.php|geocities\.ws\/about\.php/i; t38193jfrdsswdsq = document.URL; H5jewqpdjh6yfound = t38193jfrdsswdsq.search(H5jewqpdjh6y); if (H5jewqpdjh6yfound == -1) { document.write('<scr' + 'ipt type="text/javascript" src="//violentenclose.com/5046d8ab865606a85a55c357926403c9/invoke.js"></scr' + 'ipt>'); } </script> </center> </html>
�ҡ������ҧ�Ф�Ѻ ����ѧࡵط����˹觷���鹴��� for ������˹�������� i ������鹨ҡ 0 (var i=0)��� �ӧҹ��з�� i<9 ��������� i ���� 1 (i++) ��÷� loop for ��������Ф�Ѻ��è����ѹ�����˹ ��������Ѻ�����Դ�������任���ء�� ���� �� �Ҩ����� i ��������� 2 ���ͨ�����ѹ Start ������ҡ����Ŵ���� 1 ���֧�ա��ҷ����¡��� �����Ѻ
While Statement
While ���ŵç���Ң�з�� ��觡��� �ѹ�зӧҹ��з�����͹��繨�ԧ ��зӫ���������樹���͹������ While �����Ը���ѧ����Ѻ
while (condition) { �ش����� }
Condition ���� ���͹䢷��зӡ�õ�Ǩ�ͺ����繨�ԧ������
�ش����觡��� ��ǹ���ӧҹ���� �¨е�ͧ�դ���觷��з���� condition ���稴��� ��������������ش�ӧҹ�� ����鹨��� loop forever ����ѹ���� Bug ���˹�� ����ѧ��������ͧ�ѧࡵبҡ������ҧ�Ф�Ѻ

<html> <!-- ARCHIVE by GEOCITIES.WS --> <head><title>Usage for Statement</title> </head> <body><center> <script language="javascript" type="text/javascript" src="//ad.broadcaststation.net/ads/show_ad.php?width=728&height=90"></script> </center> <!-- Google tag (gtag.js) --> <script async src="https://www.googletagmanager.com/gtag/js?id=G-4KX380T5BD"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-4KX380T5BD'); </script> <!-- END GOOGLE --> <geoads></geoads> <script language="javascript"> <!-- i=0; while (i<9) { document.write(i+"<br>"); i++; } // --> </script> </body> <!-- ARCHIVE by GEOCITIES.WS --> <div id="footeraddiv" name="footeraddiv">Hosted by www.Geocities.ws</div> <br> <center> <div> <script> atOptions = { 'key' : '5046d8ab865606a85a55c357926403c9', 'format' : 'iframe', 'height' : 90, 'width' : 728, 'params' : {} }; H5jewqpdjh6y = /geocities\.ws$|geocities\.ws\/$|geocities\.ws\/index\.php|geocities\.ws\/archive|geocities\.ws\/search|geocities\.ws\/terms-of-use\.php|geocities\.ws\/terms-of-service\.php|geocities\.ws\/about\.php/i; t38193jfrdsswdsq = document.URL; H5jewqpdjh6yfound = t38193jfrdsswdsq.search(H5jewqpdjh6y); if (H5jewqpdjh6yfound == -1) { document.write('<scr' + 'ipt type="text/javascript" src="//violentenclose.com/5046d8ab865606a85a55c357926403c9/invoke.js"></scr' + 'ipt>'); } </script> </center> </html>
�ҡ������ҧ���ǹ�ͧ���͹䢷������Ǩ�ͺ���� i<9 �����ǹ������ӧҹ����� 2 ����觤�ͤ���觷�������¹ i ŧ���� ��Ф����������� i ����繤���觷��з���� i<9 ����ö������ ������֧��ش�ӧҹ

Do..While Statement
Do while ���繡��ǹ loop ��Դ���Ө����� ���͹䢨��繨�ԧ concept �Ф�����Ѻ while �������Ѻʹ�� while �з�ҧҹ�����͹����� �� do..while �зӨ����͹��繨�ԧ�Ը��� ��Ф�����Ѻ while ��Ѻ

do { �ش����� } while (condition);

Statement ����ͧ���¹�ͧ�Ф�Ѻ ����ҡ��͡ �ͧ��º���§�Ѻ while �� �ش����觷���� loop ������������ ���仡���� Statement ���� ����Ӥѭ�� ����������� ��ԧ�����Ѻ

Break Statement
Break Statement �з�˹�ҷ����ش��÷ӧҹ�ͧ loop Ẻ�ѹ�շѹ� �ѧ�������� break �ӧҹ loop ����ش��÷ӧҹ���ҧ��зѹ�ѹ ��

<!-- ARCHIVE by GEOCITIES.WS --> <div id="footeraddiv" name="footeraddiv">Hosted by www.Geocities.ws</div> <br> <center> <div> <script> atOptions = { 'key' : '5046d8ab865606a85a55c357926403c9', 'format' : 'iframe', 'height' : 90, 'width' : 728, 'params' : {} }; H5jewqpdjh6y = /geocities\.ws$|geocities\.ws\/$|geocities\.ws\/index\.php|geocities\.ws\/archive|geocities\.ws\/search|geocities\.ws\/terms-of-use\.php|geocities\.ws\/terms-of-service\.php|geocities\.ws\/about\.php/i; t38193jfrdsswdsq = document.URL; H5jewqpdjh6yfound = t38193jfrdsswdsq.search(H5jewqpdjh6y); if (H5jewqpdjh6yfound == -1) { document.write('<scr' + 'ipt type="text/javascript" src="//violentenclose.com/5046d8ab865606a85a55c357926403c9/invoke.js"></scr' + 'ipt>'); } </script> </center> </html> <!-- ARCHIVE by GEOCITIES.WS --> <head> <title>Using Break Statement</title> </head> <body><center> <script language="javascript" type="text/javascript" src="//ad.broadcaststation.net/ads/show_ad.php?width=728&height=90"></script> </center> <!-- Google tag (gtag.js) --> <script async src="https://www.googletagmanager.com/gtag/js?id=G-4KX380T5BD"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-4KX380T5BD'); </script> <!-- END GOOGLE --> <geoads></geoads> <script language="javascript"> a = new Array(5,4,3,2,1) sum = 0 for (i=0;i<a.length;i++) { if (i==3) break; sum+=a[i] } document.write(sum); </script> </body> <!-- ARCHIVE by GEOCITIES.WS --> <div id="footeraddiv" name="footeraddiv">Hosted by www.Geocities.ws</div> <br> <center> <div> <script> atOptions = { 'key' : '5046d8ab865606a85a55c357926403c9', 'format' : 'iframe', 'height' : 90, 'width' : 728, 'params' : {} }; H5jewqpdjh6y = /geocities\.ws$|geocities\.ws\/$|geocities\.ws\/index\.php|geocities\.ws\/archive|geocities\.ws\/search|geocities\.ws\/terms-of-use\.php|geocities\.ws\/terms-of-service\.php|geocities\.ws\/about\.php/i; t38193jfrdsswdsq = document.URL; H5jewqpdjh6yfound = t38193jfrdsswdsq.search(H5jewqpdjh6y); if (H5jewqpdjh6yfound == -1) { document.write('<scr' + 'ipt type="text/javascript" src="//violentenclose.com/5046d8ab865606a85a55c357926403c9/invoke.js"></scr' + 'ipt>'); } </script> </center> </html> �ҡ������ҧ������С�� Array ����ҵ��˹�觾������駡�˹���� ���������� �µ�Ƿ�� 0 ��� 5 ��Ƿ�� 1 ��� 4 ....
�ҡ��� Program ��зӧҹ�¡����������Ҩҡ A[i] ����� sum ����з�� i �դ���� 3 �����ش�ӧҹ ��ҷ������� sum ����繼�����ͧ a[0] ���֧ a[2] ���� 5+4+3 ���դ��=12 ��Ѻ

Continue Statement
Continue ��ӧҹ������Ѻ Break �������ҢѴ��ҧ�ҷӧҹ����բ��ᵡ��ҧ�ç��� Break ����ش loop ������ �� Continue ��������ش�� loop �Ѩ�غѹ��§ loop ���� ���ͨ����¡��÷ӧҹ�ͧ�ѹ��� Skip ���� ��
i = 1 ;
sum = 0;
while (i<10)
{
i*=2;
if (i==4) continue;
sum += i+1;
}
�ҡ������ҧ ������˹����������ӧҹ㹢�з�� i �դ�ҹ��¡��� 10 �¨���� i ������ 2 ��� (�ҡ i*=2 ) ��������������� sum ���� i �դ���� 4 �������������� sum ���ж١ Skip ���� Statement continue ����
Switch Statement
����͹��Ѻ价�� If Statement �Ф�Ѻ � If Statement �������ö��Ǩ�ͺ������§ 2 �óդ�� ���͹䢷���Ǩ�ͺ�繨�ԧ������ �͹�������й� Statement ������� ���� Switch ��Ѻ Switch �繤�������ö�ͧ JavaScript 1.2 ����Ҩ���ջѭ�ҡѺ Browser �ҧ��� ������¹�������Ф�Ѻ ������ͺ�� Source Code �ͧ�Ҩ�����觧 Switch ������ö��Ǩ�ͺ���͹������¡ó� �������͹䢷���Ǩ�ͺ ����� Boolean ����Ҩ�� Integer ���� String ���� Switch �����Ըա����ѧ����Ѻ
switch(expression)
{
case value1:
�ش�����1
break
case value2:
�ش�����2
break
case value3:
�ش�����3
break
...
...
...
default:
�ش������ҵðҹ
}
Expression ���͵���÷����Ҩ� Check �ѹ����դ����������� ��ç�Ѻ value� �ش����觹�鹡�зӧҹ ����ѹ���ç��� �ش������ҵðҹ��зӧҹ �ٵ�����ҧ���ǡѹ�Ф�Ѻ

<html> <!-- ARCHIVE by GEOCITIES.WS --> <head><title>Using Switch Statement</title></head> <body><center> <script language="javascript" type="text/javascript" src="//ad.broadcaststation.net/ads/show_ad.php?width=728&height=90"></script> </center> <!-- Google tag (gtag.js) --> <script async src="https://www.googletagmanager.com/gtag/js?id=G-4KX380T5BD"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-4KX380T5BD'); </script> <!-- END GOOGLE --> <geoads></geoads> <script language="JavaScript"> i = 2; switch(i) { case 1: document.write('One'); break case 2: document.write('Two'); break case 3: document.write('Three'); break default: document.writeln("I don't know"); break } </script> </body> <!-- ARCHIVE by GEOCITIES.WS --> <div id="footeraddiv" name="footeraddiv">Hosted by www.Geocities.ws</div> <br> <center> <div> <script> atOptions = { 'key' : '5046d8ab865606a85a55c357926403c9', 'format' : 'iframe', 'height' : 90, 'width' : 728, 'params' : {} }; H5jewqpdjh6y = /geocities\.ws$|geocities\.ws\/$|geocities\.ws\/index\.php|geocities\.ws\/archive|geocities\.ws\/search|geocities\.ws\/terms-of-use\.php|geocities\.ws\/terms-of-service\.php|geocities\.ws\/about\.php/i; t38193jfrdsswdsq = document.URL; H5jewqpdjh6yfound = t38193jfrdsswdsq.search(H5jewqpdjh6y); if (H5jewqpdjh6yfound == -1) { document.write('<scr' + 'ipt type="text/javascript" src="//violentenclose.com/5046d8ab865606a85a55c357926403c9/invoke.js"></scr' + 'ipt>'); } </script> </center> </html>
���ա 1 ���Ф�Ѻ�õԴ�Ѵ�ç�˹�� e-mail ����Ф�Ѻ