请教下面return的作用

cwj731 2003-08-12 04:31:09
function removeItem(catno) {

var i, j;
var tmp;

// See if the item already exists in the list, if so then decrement the quantity.

for (i = 0; i < this.items.length; i++)
if (this.items[i].catalogNumber == catno) {
this.items[i].quantity--;
if (this.items[i].quantity > 0)
return; //*****what?****/
// If the quantity drops to zero, remove the item from the list. This is done by
// making a copy the array minus the item to be deleted.

tmp = new Array();
for (j = 0; j < i; j++)
tmp[tmp.length] = this.items[j];
for (j = i + 1; j < this.items.length; j++)
tmp[tmp.length] = this.items[j];
this.items = null;
this.items = tmp;
}
}
return 是跳出此循环还是返回值还是....?
...全文
43 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
WYlslrt 2003-08-12
  • 打赏
  • 举报
回复
cwj731 2003-08-12
  • 打赏
  • 举报
回复
是不是return执行,后面的语句就不执行了?
cloudchen 2003-08-12
  • 打赏
  • 举报
回复
返回值,返回undefined
基本上和return false一样

87,987

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧