Skip to content

Instantly share code, notes, and snippets.

@everthis
Last active June 20, 2017 06:39
Show Gist options
  • Save everthis/d7db43f24019604064ac1572d8447cea to your computer and use it in GitHub Desktop.
Save everthis/d7db43f24019604064ac1572d8447cea to your computer and use it in GitHub Desktop.
quiz
  1. img标签的alt和title分别有什么作用?

  2. 类似 ul { MaRGin: 10px; } 这样的CSS属性名是大小写敏感的吗?

  3. lorem的颜色是什么颜色?

<style>
ul#awesome {
    color: red;
}
ul.shopping-list li.favorite span {
    color: blue;
}
</style>
<ul class="shopping-list" id="awesome">
    <li><span>random</span></li>
    <li class="favorite" id="must-buy"><span class="highlight">lorem</span></li>
</ul>
  1. 关于#example元素的定位描述正确的是:
#example {
    margin-bottom: -5px;
}
<p id="example">Hello</p>
  • #example向下移动5px
  • #example后的所有元素向上移动5px
  • 其他
  1. 页面加载时 mypic.jpg这张图片会被浏览器加载吗?
<style>
#test2 {
    background-image: url('mypic.jpg');
    display: none;
}
</style>
<div id="test1">
    <span id="test2"></span>
</div>
  1. 4 + 3 + 2 + "1"的输出?

  2. 以下代码alert的值是什么?

var foo = 1;
function bar() {
	foo = 10;
	return;
	function foo() {}
}
bar();
alert(foo);
  1. 选择以下代码的输出:
var x = 3;

var foo = {
    x: 2,
    baz: {
        x: 1,
        bar: function() {
            return this.x;
        }
    }
}

var go = foo.baz.bar;

alert(go());
alert(foo.baz.bar());
  • 1, 2
  • 1, 3
  • 2, 1
  • 2, 3
  • 3, 1
  • 3, 2
  1. 选择以下代码输出:
var x   = 4,
    obj = {
        x: 3,
        bar: function() {
            var x = 2;
            setTimeout(function() {
                var x = 1;
                alert(this.x);
            }, 1000);
        }
    };
obj.bar();
  • 1
  • 2
  • 3
  • 4
  • undefined
  1. 描述一下事件委托(event delegation)

  2. 编写程序:实现扁平化数组

比如:
输入:[1, [2], [3, [[4]]]],返回[1, 2, 3, 4]
输入:[1, [2, 3], [4,5]], 返回[1, 2, 3, 4, 5]
  1. 实现一个函数 find(obj, str),满足:
如var obj = {a:{b:{c:1}}};
find(obj,'a.b.c') //1
find(obj,'a.d.c') //undefined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment