第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

關(guān)于underscore _.random 負(fù)數(shù)取隨機(jī)數(shù)的問(wèn)題?

關(guān)于underscore _.random 負(fù)數(shù)取隨機(jī)數(shù)的問(wèn)題?

Smart貓小萌 2018-09-11 13:26:59
1.underscore里面有一個(gè)方法_.random,定義如下:// Return a random integer between min and max (inclusive). // integer : {-1,0,1} 負(fù)整數(shù) 、 0 、正整數(shù) // https://zh.wikipedia.org/wiki/%E6%95%B4%E6%95%B0 // [x,y]包括y,注意與Math.random的區(qū)別_.random = function(min, max) {    if (max == null) {        max = min;        min = 0;     }    return min + Math.floor(Math.random() * (max - min + 1)); };再傳入正整數(shù)的時(shí)候沒(méi)有問(wèn)題:帶入10,(max=10,min=0)return 0 + Math.floor(Math.random()*(10-0)+1); return 0 + Math.floor( [0,1)*11 ); return 0 + Math.floor( [0,11) );     return 0 + [0,10];     return [0,10]會(huì)生成一個(gè)0-10包括0,10之間的整數(shù)但是如果傳入一個(gè)-10(max = -10,min = 0):return 0 + Math.floor(Math.random()*(-10-0)+1); return 0 + Math.floor( [0,1)* -9 ); return 0 + Math.floor( [0,-9) );     return 0 + [0,-9];     return [0,-9]這樣只會(huì)生成0,-9包括0,-9之間的整數(shù),沒(méi)有-10。這樣的話:Return a random integer between min and max (inclusive) 返回一個(gè)min到max(包括)之間的一個(gè)隨機(jī)整數(shù)上面這句話就有問(wèn)題了?負(fù)數(shù)的時(shí)候,無(wú)法生成最小的邊界值。不知道我這樣理解對(duì)不對(duì),望指正
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 908 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)