最近因为一些原因想要换份工作,通过猎头帮我投递了几家公司,收到了蚂蚁、字节和拼多多的面试邀约,先来说下面试的结果
- 蚂蚁:收到 offer,定级 P6+
- 字节:收到 offer,定级 2-1
- 拼多多:1 面之后未继续流程
拼多多
先来说说拼多多,本来投的是 C 端,结果鬼使神差简历去到了 A 端(管理后台),一面简单了解之后并不愿意去做 A 端,之后也就没有继续后续的流程了。
一面
合并两个数组
concat、for 循环、扩展运算法、push.apply 这些方法都可以
合并两个对象
Object.assign、扩展运算法、手写深浅拷贝 都可以
interface 和 type 的区别
常规题,网上资料很多了,还是看官网的说明比较好
- An interface can be named in an extends or implements clause, but a type alias for an object type literal cannot.
- An interface can have multiple merged declarations, but a type alias for an object type literal cannot.
flex: 0 1 auto 表示什么意思
flex: 0 1 auto 其实就是弹性盒子的默认值,表示 flex-grow
, flex-shrink
和 flex-basis
的简写,分别表示放大比例、缩小比例、分配多余空间之前占据的主轴空间。
详细的可以看下 第 154 题:弹性盒子中 flex: 0 1 auto 表示什么意思
求字符串数组的最长公共前缀
比如输入: [“flower”,“flow”,“flight”],输出: “fl”
解题思路是先获取数组中的最大值及最小值字符串,最小字符串与最大字符串的最长公共前缀也为其他字符串的公共前缀,即为字符串数组的最长公共前缀
var longestCommonPrefix = function(strs) {
if (strs === null || strs.length === 0) return "";
if(strs.length === 1) return strs[0]
let min = 0, max = 0
for(let i = 1; i < strs.length; i++) {
if(strs[min] > strs[i]) min = i
if(strs[max] < strs[i]) max = i
}
for(let j = 0; j < strs[min].length; j++) {
if(strs[min].charAt(j) !== strs[max].charAt(j)