xgqfrms / FEIQA

FEIQA: Front End Interviews Question & Answers
https://feiqa.xgqfrms.xyz
MIT License
7 stars 0 forks source link

variable & replace & JavaScript #8

Open xgqfrms opened 6 years ago

xgqfrms commented 6 years ago

How to use a variable in replace function of JavaScript ?

variable & replace & JavaScript

https://stackoverflow.com/questions/10136097/mystring-replace-variable-but-globally


let message = "[JIRA编号]:GFT-4596\n[修改内容]:request更换请求参数EndDate\n[提交类型]:阶段性递交\n[需要测试]:是",
    jiraId = "GFT-4596";

let regex = new RegExp(jiraId, "ig",
    new_message = message.replace(regex, `<a data-links="jira" href="http://abc.xyz.com/browse/${jiraId}">${jiraId}</a>`);

image

return new string

image


https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace

http://burnignorance.com/php-programming-tips/how-to-use-a-variable-in-replace-function-of-javascript/

xgqfrms commented 6 years ago

Content-Type

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type

https://en.wikipedia.org/wiki/MIME

https://stackoverflow.com/questions/477816/what-is-the-correct-json-content-type

Content-Type: text/json

https://www.w3.org/Protocols/rfc1341/4_Content-Type.html


Content-Type: text/html; charset=utf-8
Content-Type: text/plain; charset=utf-8
Content-Type: application/json
xgqfrms commented 6 years ago

CORS

1,新建一个新的 Chrome 的快捷链接, 如图设置 "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-web-security --user-data-dir=D:\chrome 这样就会创建一个支持CORS 的 Chrome 的副本。

image

  1. Nginx 设置 反向代理。
xgqfrms commented 6 years ago

sweet alert


$ npm i -S sweetalert

import swal from "sweetalert";

https://sweetalert.js.org/

https://github.com/sweetalert2/sweetalert2

xgqfrms commented 6 years ago

shit z-index

image

xgqfrms commented 6 years ago

once


        setTimeout(() => {
            let btn = document.querySelector(`a.layui-layer-btn0`),
                btnClose = document.querySelector(`a.layui-layer-btn1`);
            btn.addEventListener(`click`, (e) => {
                // console.log(`e =`, e);
                // console.log(`e.target =`, e.target);
                // console.log(`e.target.parentNode =`, e.target.parentNode);
                // once
                // e.target.parentNode.setAttribute("disabled", true);
                // e.target.parentNode.classList.add("btn-disabled");
                e.target.setAttribute("disabled", true);
                e.target.classList.add("btn-disabled");
                e.target.href = "javascript:void(0)";
                e.target.style.display = "none";
                btnClose.innerHTML = "关闭";
            });
        }, 0);
xgqfrms commented 6 years ago

https://raw.githubusercontent.com/getlantern/loconf/master/desktop-ui.json?_0.14122228855879992

xgqfrms commented 6 years ago

locked

image

SE6

https://wesbos.com/new-es6-string-methods/

https://github.com/xgqfrms-GitHub/webgeeker/blob/gh-pages/ES6-tutorial/String/readme.md

https://wesbos.com/destructuring-default-values/

code. eat. sleep. loop ✌

https://scotch.io/

https://www.codeschool.com/

https://www.freecodecamp.com/

https://www.codecourse.com/

xgqfrms commented 6 years ago

QR code

https://www.xgqfrms.xyz/

https://qr-adv.com/index.html?u=689819&success=1

xgqfrms commented 6 years ago

asm.js & Emscripten

WebAssembly

https://github.com/kripken http://www.ruanyifeng.com/blog/2017/09/asmjs_emscripten.html

xgqfrms commented 6 years ago

http://www.ruanyifeng.com/blog/2014/03/undefined-vs-null.html

https://speakingjs.com/

https://segmentfault.com/a/1190000003971627

https://segmentfault.com/a/1190000004249679

https://davidwalsh.name/node-environment-variables

xgqfrms commented 6 years ago

image

xgqfrms commented 6 years ago

js foreach & break

http://cwestblog.com/2011/06/30/javascript-foreach-with-breaking/

https://stackoverflow.com/questions/2641347/how-to-short-circuit-array-foreach-like-calling-break

MDN

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some

var BreakException = {};

try {
  [1, 2, 3].forEach(function(el) {
    console.log(el);
    if (el === 2) throw BreakException;
  });
} catch (e) {
  if (e !== BreakException) throw e;
}

Don't use Array.forEach, use for() instead

https://coderwall.com/p/kvzbpa/don-t-use-array-foreach-use-for-instead

for

https://jsperf.com/fast-array-foreach

image