涓夊崄閬揓S甯歌绋嬪簭棰?涓€)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了涓夊崄閬揓S甯歌绋嬪簭棰?涓€)相关的知识,希望对你有一定的参考价值。

鏍囩锛?a href='http://www.mamicode.com/so/1/%e6%95%b0%e6%8d%ae' title='鏁版嵁'>鏁版嵁   val   string   ice   鏂瑰紡   upper   cti   htm   rand   

1銆佸啓鍑轰唬鐮佸涓嬪垪鏁扮粍鍘婚噸骞朵粠澶у埌灏忔帓鍒梴5,2,3,6,8,6,5,4,7,1,9}

function fn(arr){
for (var i = 0; i < arr.length-1; i++) {
for (var j = 0; j < arr.length-1-i; j++) { if(arr[ j]<arr[ j+1]){
var temp = arr[ j]; arr[ j]=arr[ j+1]; arr[ j+1]=temp;
                           }
                 }
}
for (i = 0; i < arr.length; i++) { var c=arr[i];
for (var s = i+1; s < arr.length; s++) { if(arr[s]==c)
arr.splice(s,1); s--;
}
}
}
return arr;
}
console.log(fn([5,2,3,6,8,6,5,4,7,1,9]).toString());

2銆佺敤 javascript 瀹炵幇鍐掓场鎺掑簭銆傛暟鎹负 23銆?5銆?8銆?7銆?2銆?3銆?4

//鍗囧簭绠楁硶function sort(arr){
for (var i = 0; i <arr.length; i++) {
for (var j = 0; j <arr.length-i; j++) { if(arr[ j]>arr[ j+1]){
var c=arr[ j];//浜ゆ崲涓や釜鍙橀噺鐨勪綅缃產rr[ j]=arr[ j+1];
arr[ j+1]=c;
}
};
};
return arr.toString();
}
console.log(sort([23,45,18,37,92,13,24]));

3銆佺敤 js 瀹炵幇闅忔満閫夊彇 10鈥?00 涔嬮棿鐨?10 涓暟瀛楋紝瀛樺叆涓€涓暟缁勶紝骞舵帓搴?/p>

function randomNub(aArray, len, min, max) { if (len >= (max - min)) {
return 鈥樿秴杩団€?+ min + 鈥?鈥?+ max + 鈥樹箣闂寸殑涓暟鑼冨洿鈥?+ (max - min - 1) + 鈥樹釜
鐨勬€绘暟鈥?
}
if (aArray.length >= len) {
aArray.sort(function(a, b) { return a - b
});
return aArray;
}
var nowNub = parseInt(Math.random() * (max - min - 1)) + (min + 1); for (var j = 0; j < aArray.length; j++) {
if (nowNub == aArray[ j]) { randomNub(aArray, len, min, max); return;
}
}
aArray.push(nowNub); randomNub(aArray, len, min, max); return aArray;
}
var arr=[]; randomNub(arr,10,10,100);

4銆佸凡鐭ユ暟缁?var stringArray = [鈥淭his鈥? 鈥渋s鈥? 鈥淏aidu鈥? 鈥淐ampus鈥漖锛?Alert 鍑衡€漈his is Baidu Campus鈥濄€?/p>

绛旀锛歷ar stringArray = ["This", "is", "Baidu", "Campus"] alert(stringArray.join(""))

5銆佸凡鐭ユ湁瀛楃涓?foo=鈥漡et-element-by-id鈥?鍐欎竴涓?function 灏嗗叾杞寲鎴愰┘宄拌〃绀烘硶鈥漡etElementById鈥濄€?/p>

function combo(msg){ var arr=msg.split("-"); for(var i=1;i<arr.length;i++){
arr[i]=arr[i].charAt(0).toUpperCase()+arr[i].substr(1,arr[i].length-1);
}
msg=arr.join(""); return msg;

6銆佷笅闈㈣繖娈?JS 杈撳嚭浠€涔堬紝骞剁畝杩颁负浠€涔堬紵

function Foo() { var i = 0锛?return function () { console.log(i++)锛?}
}
var f1 = Foo()锛?f2 = Foo()锛?f1()锛?f1()锛?f2()锛?console.log(i)锛?0//f1=Foo() 鐩稿綋浜?f1 璧嬪€间负鍑芥暟 Foo()鐨勮繑鍥炲€?f1=function锛堬級{ console.log(i++)
}
1//鍥犱负 f1=浜嗕竴涓?function 鎵€浠ユ湁浜嗕綔鐢ㄥ煙锛宖2 鍜?f1 涓嶅悓锛屼笉鍦ㄤ竴涓唴瀛樹腑0
鎶ラ敊  //i 涓?Foo 鍐呴儴鐨勫彉閲忓叏灞€涓嶅彲璁块棶锛屽叏灞€涓病鏈?i 鍙橀噺鎵€浠ヤ細鎶ラ敊

7 銆?鏈?杩?鏍?涓€ 涓?URL锛?http://item.taobao.com/item.htm?a=1&b=2&c=&d=xxx&e锛岃鍐欎竴娈?JS 绋嬪簭鎻愬彇 URL 涓殑鍚勪釜 GET 鍙傛暟(鍙傛暟鍚嶅拰鍙傛暟涓暟涓嶇‘瀹?锛屽皢鍏舵寜key-value 褰㈠紡杩斿洖鍒颁竴涓?json 缁撴瀯涓紝濡倇a:鈥?鈥? b:鈥?鈥? c:鈥? d:鈥?xxx鈥? e:undefined}銆?/p>

function serilizeUrl(url) { var urlObject = {};
if (/?/.test(url)) {
var urlString = url.substring(url.indexOf("?") + 1); var urlArray = urlString.split("&");
for (var i = 0, len = urlArray.length; i < len; i++) { var urlItem = urlArray[i];
var item = urlItem.split("="); urlObject[item[0]] = item[1];
}
return urlObject;
}
return null;
}

8銆乿ar numberArray = [3,6,2,4,1,5]; 锛堣€冨療鍩虹 API锛?br/>1) 瀹炵幇瀵硅鏁扮粍鐨勫€掓帓锛岃緭鍑篬5,1,4,2,6,3]

var numberArray = [3,6,2,4,1,5]; alert( numberArray .reverse())

2) 瀹炵幇瀵硅鏁扮粍鐨勯檷搴忔帓鍒楋紝杈撳嚭[6,5,4,3,2,1]

var numberArray = [3,6,2,4,1,5];
// a-b 杈撳嚭浠庡皬鍒板ぇ鎺掑簭锛宐-a 杈撳嚭浠庡ぇ鍒板皬鎺掑簭銆俷umberArray .sort(function(a,b){
return b-a}); console.log((numberArray .join()));

9銆佽緭鍑轰粖澶╃殑鏃ユ湡锛屼互 YYYY-MM-DD 鐨勬柟寮忥紝姣斿浠婂ぉ鏄?2014 骞?9 鏈?26
鏃ワ紝鍒欒緭鍑?2014-09-26

var d = new Date();
// 鑾峰彇骞达紝getFullYear()杩斿洖 4 浣嶇殑鏁板瓧var year = d.getFullYear();
// 鑾峰彇鏈堬紝鏈堜唤姣旇緝鐗规畩锛? 鏄?1 鏈堬紝11 鏄?12 鏈坴ar month = d.getMonth() + 1;
// 鍙樻垚涓や綅
month = month < 10 ? 鈥?鈥?+ month : month;
// 鑾峰彇鏃?var day = d.getDate();
day = day < 10 ? 鈥?鈥?+ day : day; alert(year + 鈥?鈥?+ month + 鈥?鈥?+ day);

10銆佸皢瀛楃涓测€?lt;tr><td>{$id}</td><td>{$name}</td></tr>鈥濅腑鐨剓$id} 鏇挎崲鎴?10锛寋$nny 锛堜娇鐢ㄦ鍒欒〃杈惧紡锛?/p>

绛?妗?锛?鈥?<tr><td>{$id}</td><td>{$id}_{$name}</td></tr> 鈥?.replace(/{$id}/g, 鈥?10鈥?.replace(/{$name}/g, 鈥楾ony鈥?;

以上是关于涓夊崄閬揓S甯歌绋嬪簭棰?涓€)的主要内容,如果未能解决你的问题,请参考以下文章

6銆?0閬揓AVA鍩虹缂栫▼缁冧範棰樿窡绛旀

涓浗绋嬪簭濯涜嚜鏇濓細鏇捐Scala澶т浆鎬ч獨鎵帮紒涓撴寫闈炶嫳璇瘝璇皬濮戝涓嬫墜

20閬揓ava楂橀闈㈣瘯棰?棰樿В

Anaconda涓畨瑁呬簡Libtiff妯″潡锛屼絾杩愯绋嬪簭鏄剧ずModuleNotFoundError: No module named 'libtiff'

涓夊崄涔濄€佸墠绔疕TML

銆愯绋嬭璁★綔C++銆慍++绋嬪簭璁捐鍩虹锛氱煩闃佃繍绠楀櫒