拼多多笔试题总结

1.font-size会引起页面reflow
2.使得页面内div不可见的是:

opacity:0

而z-index:-100和width:0,height:0不可以
3.排序算法中稳定的

不稳定:快选堆希

4.将页面一个标签内字符串标红


<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Titletitle>
head>
<body>
  <div id="p">abfifns8*daoab*rhitoq23434nhfdgoioijdiv>
  <script>
    function mark(p) {
       var str = p.innerHTML;
       var reg = /[ab\*8]/g;
       var newStr = str.replace(reg,function (item) {
         return `"color:red">${item}</span>`;
       });
      p.innerHTML = newStr;
    }
    mark(p);
  script>
body>
html>

注意:1.replace方法并不会在原字符串上更改,而是返回一个替换后字符串。
2.replace方法第一个参数为正则表达式,第二个参数为回调函数,回调函数第一个参数为匹配的字符,在回调函数内对匹配字符处理。
3.使用ES6模板字符串进行字符串连接,只需写一对反撇号即可,变量引用${}。
4.正则表达式书写注意:(1)有些字符需转义:如*;(2)全局匹配勿忘记

你可能感兴趣的:(面试题)