javascript
16é²æ°æååãæ°åã«å¤æ'ffea34'.match(/.{2}/g).map(x=>'0x'+x|0)[255, 234, 52]
https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Array/fill [].fill.call({ length: 3 }, 'ç¹°ãè¿ãããå¤'); ã§ã§ãããæ£ç´å¾®å¦
String.prototype.capitalize = function(){ return this.charAt(0).toUpperCase() + this.slice(1); } https://firegoby.jp/archives/4473
"#8f5c44".slice(1).match(/.{1,2}/g).map(x=>parseInt(x,16))
Uncaught Error: Syntax error, unrecognized expression: unsupported pseudo: visibleundefinedãããé·ãã¹ã¿ãã¯ãã¬ã¼ã¹ãåºããã æªãµãã¼ãã®çä¼¼è¦ç´ ãæå®ããã¦ããããã è¦ã¯jqueryã®selectorãééã£ã¦ãã
if(['iPhone','iPad','Android'].some( x => navigator.userAgent.includes(x) ){ . . . }
javascriptã«enumã¯ãªãã®ã§Objectã§ä»£ç¨ããã ãã ããObjectã¯readonlyã§ãªãçºãObject.freezeãã¦readonlyã«ãã¦ä½¿ãã What is the preferred syntax for defining enums in JavaScript? - Stack Overflow
someã使ãæ¹æ³ããããããã someã¨ããã¡ã½ããã®ä½¿ãæ¹ããã¯ããã°ã©ã ã®æå³ãåããã«ããã¨ããã®ã¯ãã£ã¨ãã§ãããå人éçºã ã£ããå¥ã«ãããªæ°ãããã å ´åã«ãã£ã¦ã¯ãããã°ã©ã ãçãç°¡æ½ã«æ¸ããã var result = null; var arr = ['up','doâ¦
// !ã使ã !!1; // true !!0; // false !!'zawa'; // true !!''; // false !!null; // false !!undefined; // false åå¤æã®ãããã - Qiita
ä½ãè¨ã£ã¦ããã®ãããåãããªãããããã¾ãããã ããå ±éã®é åå¦çã®ä¸ã§ãå¿ ãããã½ã¼ããå¿ è¦ãªãå ´åãããã©ã«ãå¤ã¨ãã¦ã½ã¼ãããªãç¡åé¢æ°ãè¨å®ãããã ã½ã¼ãæ¡ä»¶ãçç¥ããã¨ãããã©ã«ãã¯æååæ¯è¼ã§ã½ã¼ãããã¦ãã¾ãã®ã§ Array.soâ¦
chromeã®javascript ã³ã³ã½ã¼ã«ã§objectã®ä¸èº«ã表示ããã¨ãã« console.dir(object); or console.log(object); or object; ã¨ããã¨ããããé層æ§é ã§è¡¨ç¤ºãã¦ãããããã³ããã§ããªãã console.log(JSON.stringify(object); JSONã«å¤æããã¨ã³ããã§ãâ¦
bashã®for inã¨åãæ§æãjavascriptã«ãããããæåãå ¨ãç°ãªãã®ã§æ³¨æbashã®for inã¨åãåä½ã§è¡ãããå ´å ä»ã¯for ofæ§æããããã¡ãªã¿ã«javascriptã®for inã¯ããããããªåé¡ãæã£ã¦ãã¦ãã»ã¨ãã©ä½¿ãéããªãã for...of - JavaScript | MDN fâ¦
ä¾ãã°ãSPAãªã©require.jsã§éåæã«jqueryãå¼ã°ããå ´åãªã©ã§ãjqueryã®èªã¿è¾¼ã¿ãå®äºããã¾ã§å¾ ã¤å ´åã jqueryãåå¨ããªãå ´åã«1ç§å¾ã«ããä¸åº¦èªåèªèº«ãå¼ã³åºãããå ´åarguments.calleeã使ããä½ããarguments.calleeã¯éæ¨å¥¨ãããããç¨éã§â¦
ãã¤ã®éã«ããstartsWithãendsWithã追å ããã¦ããã æ£è¦è¡¨ç¾ã§ String.match(/^æ¯è¼æåå/) String.match(/æ¯è¼æåå$/) ã§ããããã©ãæ°æã¡çã«å¦çãéããªãæ¹ãããããªãæè¿ã®chromeã¨ãã§ã¯é¨åä¸è´ã®includesã追å ããã¦ããã chromeæ¡å¼µâ¦
C#ã¨ãã§ããªãã¿ã®startsWith endWithã使ããç°å¢ã§ã¯ä½¿ããã®ã§ããã¤ã使ãã¨ããæããã¨ã¯ str.matchã®æ£è¦è¡¨ç¾ãå®çªã§ããã é¨åä¸è´ã«ã¤ãã¦ãæ£è¦è¡¨ç¾ã使ãã®ã¯ã¤ãã¤ãã ããindexOfã¯-1ã¨æ¯è¼ãããã®ãããªããå«ã ãã¨æã£ã¦ãããããããªâ¦
$.ajaxã®åä½ã®è¨äºã¯ããã¨è¯ãã¿ããããã©ãå¤æ®µã®å ´åã®ãµã³ãã«ããªããªãè¦ã¤ãããªãã£ãã®ã§ã¡ã¢ãcallbackå°çãæãåºãçºã«ãæè¿ã¯ãjavascriptèªä½ã«generetorããpromiseãããåãã£ã¦ããããjqueryã«ã¯Deferredã¨ããä»çµã¿ãåãã£ã¦ããâ¦
ã§ããªãã®ã§ãconcatã使ãã ããã£ã¦ãããåºã¦ããªãã£ãã®ã§ã¡ã¢ Arrayã®concatã¡ã½ãããä½æ°ã«ä¾¿å©ã ã£ã - ãã¨å³
ããããã£ã¯åçã«çæãã¦ããã try { Object.defineProperty(Array.prototype, "last", { get: function(){ return this[this.length-1]; } }); }catch(e){ Array.prototype.__defineGetter__("last", function(){ return this[this.length-1]; }); } jaâ¦
è²ã ãããæ¹ã¯ããããæçµçã«ã¯ä»¥ä¸ã§è½ã¡çããã function isset (fn) { var value; try { value = fn(); } catch (e) { value = undefined; } finally { return value !== undefined; } }; console.log( isset(() => a.b.c), isset(() => a.b.c.d.e.f)â¦
ä»ãªããã¢ãã¼é¢æ°ã使ãã°ãããªããåæã«æ¸¡ãã¾ããvar that = thisã¨ãä¸æ¦å¤æ°ã«ä»£å ¥ããã.bind(this)ã¨ããã¦ããã®ãæãããã§ããã that(self)ã¨ãå¥ã®å¤æ°ã«thisãå ¥ãã奴 var self = this; something( function () { // callback stuff } ) â¦
merge(obj1,obj2); ããã ãã ã£ã for(var prop in obj2){ obj1[prop] = obj2[prop] } ã¨ããã£ã¦ããã ãããªãã¨ãããã¾ãfor inæã§ä½¿ãã©ãããªããªãã è¤éãªãªãã¸ã§ã¯ãã®ãã¼ã¸ã¨ãã«ä½¿ãã javascript ãªãã¸ã§ã¯ãã®ãã¼ã¸ãããã - Code Life
function ã£ã¦æ¸ãã®åé·ã ãªã¨æã£ã¦ãããããã¤ã®éã«ãå®è£ ããã¦ããã chromeæ¡å¼µã®éçºã ã£ãããchromeã常ã«ææ°çã«æ´æ°ãããããchrome以å¤ã®ãã¨ã èããå¿ è¦ãªãã®ã§ã使ã£ã¦ããããããããchromeæ¡å¼µã®éçºã¯ãææ°ã®æè¡ãå¿ç½®ããªãçãâ¦
formã§inputã®changeãclickã¤ãã³ãã ããã«ãªã£ãæã«ä¸ç´è ã«ä¸ããçºã®ä¸æã å®è·µãjQuery - .on()ã¨.off()ã使ãããªã 1 | CodeGrid
ä¾ã¨ãã¦ãbackgroudããã³ã³ãã³ãã¡ãã¥ã¼ããµã¤ãå´ã«éã£ã¦ ãµã¤ãå´ã®ã³ã³ãã³ãã¡ãã¥ã¼ãããchromeæ¡å¼µã®optionãã¼ã¸ãéãããå ´åãµã¤ãå´ã§aã¿ã°ã§chromeæ¡å¼µã®optionãã¼ã¸ãchrome-extention://gesdfsdfer/option.htmlãæå®ãã¦ããã»ãã¥ãªâ¦
ã¹ãã¼ããã©ã³åãã®WEBã¢ããªãä½ãã¨ãã«position fixdã使ã£ã¦ãè¦ç´ ãä¸å¤®ã«è¡¨ç¤ºãããã æããcssã§ç¸¦ä¸å¤®ã«è¦ç´ ãé ç½®ãããã®ã¯å¤§å¤ã ã£ããã©ã position fixdã使ãã¨é端ã«é£ãããªãã position: fixed; top: 50%; left: 50%; transform: transâ¦
ãããã¨æ²¢å±±ã§ã¦ãããã©ã Javascriptã®switchæã§æ£è¦è¡¨ç¾ã使ã - Qiita 俺ãæ±ãã¦ããã®ã¯ãããããªãã æ£è¦è¡¨ç¾onlyãªcaseãªãããã§ããã url='http://example.com/info.php'; with(url.compare){switch(url){ case 'http://example.com/': consoâ¦
pngãªã©ã®ééãªç´ æãåé¢ã«ç½®ãã¦ã¡ãã£ã¨ããããããã¶ã¤ã³ã使ç¨ãããã¨ããæã«ãããã話ãééã¨ããã©ãæ®éã«ãã®ã¾ã¾ã ã¨ã¯ãªãã¯ãé»å®³ãã(ç¾å®ã§è¨ãã¨ããã®ã¬ã©ã¹ãããã®ã¨åã) ã®ã§ãæã¯Javascriptã§ãã¯ãªãã¯ã¤ãã³ããééããããâ¦
ä¸çºã§ãã£ã¦ããã®ããããã£ã¦ããªãã£ãã®ã§ä½ã£ããHH:mm:ss â s '01:24:13'.split(':').reverse().reduce(function(prev,cur,idx,arr){ return prev + cur * Math.pow(60,idx); },0); 5053 ã¢ãã¼é¢æ°ã§æ¸ãã¨ãããã£ãã '01:24:13'.split(':').reverâ¦
manifest.jsonã®permissionsã«tabsã追å manifest.json "permissions": [ "tabs" ] chrome.tabs.create({url: éãããURL }); ã¨ã¦ãç°¡åéããã®ã¯... chrome.tabs.remove(tabId); ã ããéããtabã®tabIdã£ã¦ã©ããã£ã¦åå¾ããã®ã javascript - Googleâ¦
phpã®str_replaceã ã¨ç°¡å ãã¶ãããããªããã 'é','å°' => '大' ]; $str = str_replace(array_keys($replaces),array_values($replaces),$str); javascriptã ã¨é端ã«é¢åã«ãªãã ã¾ãã§åªæã®ããã var str = "å°å転", map = {"å":"é", "å°":"大"â¦