Created
September 26, 2017 06:12
-
-
Save naixy28/44918de42c087ab49eeeae6ac52fd98d to your computer and use it in GitHub Desktop.
Revisions
-
naixy28 created this gist
Sep 26, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 │ │ │ └───────┘ └───────┘ │ └───────────────────────┘ ```