面谈环节
- JS数据类型;
- 判断数据类型的方式;
- 原型链和集成;
- HTTP缓存策略;
- 页面性能优化策略;
- APP和H5通信方式;
- call/apply/bind区别;
- new关键字实现过程;
- 响应式开发方案;
- 项目难点及成长点
笔试环节
1. 请写出下面代码的输出内容
console.log(1); setTimeout(() => { console.log(2); Promise.resolve().then(data => { console.log(3); }); }); new Promise((resolve) => { resolve() console.log(4) }).then(() => { console.log(5); setTimeout(() => { console.log(6); }); }).then(() => console.log(7)) console.log(8); //输出 1 4 8 5 7 2 3 6
2.请写出下面代码的输出内容
console.log(fish1,fish2,fish3); // undefined undefined undefined var fish1 = function(){ console.log('welcome to Palfish-1') } var fish1,fish2,fish3; function fish2(){ console.log('welcome to Palfish-2') } var fish3 = 'welcome to Palfish-3' var fish1,fish2,fish3; console.log(fish1,fish2,fish3); // f1() f2() 'welcome to Palfish-3'
3.请写出下面代码的输出内容
var nickname = "LiLei"; function Person(name){ this.nickname = name; this.sayHi = function() { console.log(this.nickname); setTimeout(function(){ console.log(this.nickname); }, 1000); } } var Male = { nickname: 'xiaofang', sayHi: () => { console.log(this.nickname); } } var person = new(Person.bind(Male, 'XiaoHong')); person.sayHi(); // ==> XiaoHong LiLei
4.请写出下面代码的输出内容
let object = {a:0}; function fun(obj) { obj.a=1; obj={a:2}; obj.b=2; } fun(object); console.log(object); // ==> 输出:{a:1}
编程题(任选一)
5.实现一个LazyMan,可以按照以下方式调用:
LazyMan(“Hank”)输出: Hi! This is Hank! LazyMan(“Hank”).sleep(10).eat(“dinner”)输出 Hi! This is Hank! //等待10秒.. Wake up after 10 Eat dinner~ LazyMan(“Hank”).eat(“dinner”).eat(“supper”)输出 Hi This is Hank! Eat dinner~ Eat supper~ 以此类推。
2. 找出二叉树中某两个节点的第一个共同祖先,不得将其他的节点存储在另外的数据结构中。
例如,给定如下二叉树: root = [3,5,1,6,2,0,8,null,null,7,4],相应的树型结构为:
3 / \ 5 1 / \ / \ 6 2 0 8 / \ 7 4
示例 1: 输入: root = [3,5,1,6,2,0,8,null,null,7,4], p = 5, q = 1 输出: 3 解释: 节点 5 和节点 1 的最近公共祖先是节点 3。
示例 2: 输入: root = [3,5,1,6,2,0,8,null,null,7,4], p = 5, q = 4 输出: 5 解释: 节点 5 和节点 4 的最近公共祖先是节点 5。因为根据定义最近公共祖先节点可以为节点本身。
说明:
- 所有节点的值都是唯一的
- p、q 为不同节点且均存在于给定的二叉树中。
// 二叉树数据结构: function TreeNode(val) { this.val = val; this.left = this.right = null; } // your code here:
全部评论
(4) 回帖