2018-05-11 高思总结

1.扩展String的原型方法,实现trim,删除空格

if(!String.prototype.trim){
  Sting.prototype.trim = function(){
    return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
  }
}

2.考察函数声明提前,以及JS分解析和执行阶段

var a =1;
function A(){
  a =3;
  return;
  function a(){}
}
A();
console.log(a)//1

如果此时改为

var a =1;
function A(){
  a =3;
  return;
}
A();
console.log(a)//3

3.考察作用域

var arr1=[1,2,3,4,5],arr2=[];
fot(var i=0;i<arr.length;i++){
   arr2.push(function(){alert(i)});
}
console.log(arr2[3]());//5

4.左定宽,右自适应

1⃣️position +margin
//html
<div class='left'>定宽</div>
<div class='right'>自适应</div>
//css
.left{
  width:200px;
  height:660px;
  position:absolute;
  top:0;
  left:0;
}
.right{
  height:660px;
  margin-left:200px;
}
2⃣️float + margin
//html
<div class='left'>定宽</div>
<div class='right'>自适应</div>
//css
.left{
  width:200px;
  height:660px;
  float:left;
}
.right{
  height:660px;
  margin-left:200px;//或者overflow:hidden;
}

3⃣️flex布局

//html
<div class="parent">
  <div class='left'>定宽</div>
<div class='right'>自适应</div>
</div>
//css
.parent{
  display:flex;
}
.left{
  width:200px;
  height:660px;
}
.right{
  height:660px;
  flex:1;
}
5⃣️table

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <!--5 table-->
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        /*table 的显示特性为 每列的单元格 宽度和 一定等于 表格宽度。
         table-layout: fixed 可加速渲染,也是设定布局优先。
         table-cell 中不可以设置 margin 但是可以通过 padding 来设置间距*/

        .parent {
            /*必须有100%宽度*/
            display: table;
            table-layout: fixed;
            width: 100%;
        }

        .left {
            width: 200px;
            height: 600px;
            background: red;
            text-align: center; /*文字水平居中*/
            line-height: 600px; /*文字垂直居中*/
            color: #fff;

            display: table-cell;
        }

        .right {
            height: 600px;
            background: yellow;
            text-align: center; /*文字水平居中*/
            line-height: 600px; /*文字垂直居中*/

            display: table-cell;
        }
    </style>
</head>
<body class="parent">
<div class="left">定宽</div>
<div class="right">自适应</div>
</body>
</html>

5.js事件循环

https://yangbo5207.github.io/wutongluo/ji-chu-jin-jie-xi-lie/shi-si-3001-es6-chang-yong-zhi-shi-he-ji.html

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 1.从载入EasyUI开始 读者需要到EasyUI官网中下载包含原文件和demo的压缩包,并解压到之前编写的代码目...
    老皮丘阅读 5,848评论 0 6
  • 诗经全文及译文 《诗经》现存诗歌305篇,包括西周初年到春秋中叶共 500 余年的民歌和朝庙乐章,分为风、雅、颂三...
    观茉阅读 70,857评论 0 18
  • 1.路遙中篇小说名作选LU YAO ZHONG PIAN XIAO SHUO MING ZUO XUAN /路 遙...
    树欲静阅读 3,907评论 0 0
  • 天地玄黄 宇宙洪荒 日月盈昃 辰宿列张 寒来暑往 秋收冬藏 天:颠也,至高无上。从一、大。他前切。 地:元气初分,...
    若零F阅读 9,426评论 2 23
  • 正月十六,这边的习俗吃过晚饭家人一起到街上遛弯,俗称遛百病。遛一遛,百病消。这会儿家人都出去了,我一人在家抱二宝。...
    大仙鹤阅读 861评论 0 1

友情链接更多精彩内容