360前端面试题

1.URI的组成

应该是URL的组成:协议、存有该资源的主机的IP地址(有时也包括端口号)、主机资源的具体地址(如目录和文件等)

http://www.cnblogs.cn:8080/yanyangbyou/#section?q=javascript

location.hash 返回 #后的零个或多个字符

location.host 返回 服务器名称和端口号 www.cnblogs.cn:8080

location.hostname 返回 不带端口号的服务器名称 www.cnblogs.cn

location.port 返回 URL中指定的端口号 8080

location.protocol 返回 页面中使用的协议 http:

location.pathname 返回 URL中的目录和(或)文件名

location.search 返回 URL 中的查询字符串 ?q=javascript

location.href 返回当前页面的完整的URL

2.获取父节点下的第一个和最后一个元素

获取第一个元素:

  someNode.firstChild

  someNode.childNodes[0]

获取最后一个元素:

  someNode.lastChild

  someNode.childNodes[someNode.childNodes.length-1]

3.callee属性、caller属性、call() 和 apply()、bind()

在函数内部有两个特殊的对象:arguments 和 this 。

arguments 的主要用途是保存函数参数。arguments 对象有一个callee 的属性。arguments.callee指向拥有这个arguments对象的函数。arguments.callee:指向当前函数。 

this :谁调用该函数,this指代的就是谁。

caller :函数对象的属性,保存着调用当前函数的函数的引用。

bind(): this 值绑定到函数中。var function1 = functionName.bind(o); function1();

function outer(){
  inner();
}
function inner(){
  alert(arguments.callee);
}
outer(); //输出的是 inner函数

===========================

function outer(){
  inner();
}
function inner(){
  alert(arguments.callee.caller);
}
outer(); //输出的是 outer 函数

2.证明时间存在捕获阶段和冒泡阶段

我就用addEventListener绑定个单击事件,一个用false,一个用true,然后弹出不同的值。

3.理解block formatting context(BFC块级上下文)的概念

3.找出数组中出现次数最多的数字和个数

4.写一个快排

原文地址:https://www.cnblogs.com/yanyangbyou/p/4026363.html