Skip to content

Instantly share code, notes, and snippets.

@naixy28
Created September 26, 2017 06:12
Show Gist options
  • Select an option

  • Save naixy28/44918de42c087ab49eeeae6ac52fd98d to your computer and use it in GitHub Desktop.

Select an option

Save naixy28/44918de42c087ab49eeeae6ac52fd98d to your computer and use it in GitHub Desktop.

Revisions

  1. naixy28 created this gist Sep 26, 2017.
    88 changes: 88 additions & 0 deletions int-simple.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,88 @@
    ## js
    1. 输出
    ```javascript
    function Foo() {
    getName = function() {alert(1)};
    return this;
    }
    Foo.getName = function() {alert(2)};
    Foo.prototype.getName = function() {alert(3)};
    var getName = function() {alert(4)};
    function getName() {alert(5)};

    // output
    Foo.getName();
    getName();
    Foo().getName();
    getName();
    new Foo.getName();
    new Foo().getName();
    new new Foo().getName();
    ```

    2. 写出函数test()
    ```javascript
    /**
    * @function poll, randomly returns a boolean value
    * @return {Boolean}
    */
    function poll() {...}

    /**
    * @function test, 每隔n秒执行一次poll,若poll返回值为true, 则执行callback,否则在
    * n = 1.5 * n 秒后再次执行直到poll返回true, n 初始值为1
    * @param {function} poll
    * @param {function} callback
    */
    function test(poll, cb) {...}
    ```

    3. 写出函数add()
    ```javascript
    add(1)(2) // 3
    add(1,2) // 3

    ```


    4. 输出
    ```javascript
    setTimeout(function () {
    console.log(1);
    }, 0);

    new Promise(function executor(resolve) {
    console.log(2);
    for (var i = 0; i < 10000; i++) {
    i == 9999 && resolve();
    }
    console.log(3);
    }).then(function () {
    console.log(4);
    });

    console.log(5);
    ```


    ## CSS
    1. 写出.clearfix类,用于清除浮动
    2. 使用flex布局实现
    ```css
    screen width > 768px
    ┌───────────────────────┐
    │ ┌────┐ ┌────┐ ┌────┐ │
    │ │ a │ │ b │ │ c │ │
    │ └────┘ └────┘ └────┘ │
    └───────────────────────┘

    screen width <= 768px
    ┌───────────────────────┐
    │ ┌──────────────────┐ │
    │ │ b │ │
    │ └──────────────────┘ │
    │ ┌───────┐ ┌───────┐ │
    │ │ a │ │ c │ │
    │ └───────┘ └───────┘ │
    └───────────────────────┘
    ```