課程
/前端開發(fā)
/JavaScript
/JavaScript進階篇
length去掉之后就沒有反應了。不是已經(jīng)定義函數(shù)了嗎,為什么還要加length
2016-08-18
源自:JavaScript進階篇 4-8
正在回答
var i=mynum.length;
var a=0;
// do{
// ? ? if(mynum[a]>=60)
// ? ? {
// ? ? ? ? document.write(mynum[a]+":pass,go on ~ <br/>");
// ? ? }else{
// ? ? ? ? document.write(mynum[a]+":fail,stop! <br/>");
// ? ? ? ? break;
// ? ? }
// ? ? i--;
// ? ? a++;
// }while(i>0)
// while(i>0){
// ? ? if(mynum[a]>=60){
// ? ? ?document.write(mynum[a]+":pass,go on ~ <br/>"); ??
// ? ? ? document.write(mynum[a]+":fail,stop! <br/>");
// ? ? ? break;?
// }
for(var a=0;a<=i;a++){
? ? ?if(mynum[a]>=60){
? ? ? ?document.write(mynum[a]+":pass,go on ~ <br/>"); ?
? ? ?}else{
? ? ? ?document.write(mynum[a]+":fail,stop! <br/>");
? ? ? ?break;
? ? ?}
}
length也可以理解為數(shù)組里元素的個數(shù),一個數(shù)組里有5個元素,則length為5
length就是長度,document.write(arr.length);理解為輸出arr的長度,這個點就理解為“的”好了,比如有一個數(shù)組名字為dmu,想獲取這個數(shù)組dmu的長度,就寫成 dmu.length(讀作”數(shù)組dmu的長度“)
var mynum =new Array(70,80,66,90,50,100,89);//定義數(shù)組mynum并賦值
var i=0;
while(i<mynum.length)
整數(shù)不能和數(shù)組進行比較,所以length去掉之后就沒有反應,出錯了。
舉報
本課程從如何插入JS代碼開始,帶您進入網(wǎng)頁動態(tài)交互世界
2 回答i<length與i<length-2?
5 回答"Hello".length中l(wèi)ength的意思?
1 回答.length和.length-1有什么不一樣嗎?
2 回答數(shù)組屬性length
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學習伙伴
掃描二維碼關注慕課網(wǎng)微信公眾號
2016-11-08
var i=mynum.length;
var a=0;
// do{
// ? ? if(mynum[a]>=60)
// ? ? {
// ? ? ? ? document.write(mynum[a]+":pass,go on ~ <br/>");
// ? ? }else{
// ? ? ? ? document.write(mynum[a]+":fail,stop! <br/>");
// ? ? ? ? break;
// ? ? }
// ? ? i--;
// ? ? a++;
// }while(i>0)
// while(i>0){
// ? ? if(mynum[a]>=60){
// ? ? ?document.write(mynum[a]+":pass,go on ~ <br/>"); ??
// ? ? }else{
// ? ? ? document.write(mynum[a]+":fail,stop! <br/>");
// ? ? ? break;?
// ? ? }
// ? ? i--;
// ? ? a++;
// }
for(var a=0;a<=i;a++){
? ? ?if(mynum[a]>=60){
? ? ? ?document.write(mynum[a]+":pass,go on ~ <br/>"); ?
? ? ?}else{
? ? ? ?document.write(mynum[a]+":fail,stop! <br/>");
? ? ? ?break;
? ? ?}
}
2016-08-18
length也可以理解為數(shù)組里元素的個數(shù),一個數(shù)組里有5個元素,則length為5
2016-08-18
length就是長度,document.write(arr.length);理解為輸出arr的長度,這個點就理解為“的”好了,比如有一個數(shù)組名字為dmu,想獲取這個數(shù)組dmu的長度,就寫成 dmu.length(讀作”數(shù)組dmu的長度“)
2016-08-18
var mynum =new Array(70,80,66,90,50,100,89);//定義數(shù)組mynum并賦值
var i=0;
while(i<mynum.length)
整數(shù)不能和數(shù)組進行比較,所以length去掉之后就沒有反應,出錯了。