图森前端一面
面的好难啊。。都是很细节的题目
1.怎么解决跨域问题?我说用的代理
2.为什么代理之后就不存在跨域问题了?
3.代理服务器和服务器之间存在跨域问题吗?
4.其他解决跨域的方法 jsonp、cors
5.cors要设置哪些参数
6.是不是每添加一个前端页面就要重启服务器改变cors的参数?
7.把allow-origin设置为*会有什么问题?
8.页面上线之后还能用代理服务器的方式避免跨域吗?
9.什么请求会触发cors的预检,为什么会有预检,预检增加了请求次数,这有什么好处?
10.讲一下登录注册的过程。
11.session和token有什么区别,为什么你的项目里要用token
12.说一下xss和csrf
13.说一下bfc,有什么方法可以创建一个bfc?overflow:hidden,position:absolute都有副作用,有没有没有副作用的方法?
14.了解ifc、ffc、gfc吗?
15.你的项目是怎么做状态管理的?我说没做状态管理用的props
16.如果多级组件传递状态怎么办?
17.redux将状态存在什么地方?
18.如果页面刷新之后store存的状态会重置吗?
19.说一下原型和原型链
20.
function fn(){}
fn.__proto__ === ?
String.__proto__ === ?
21.
new fn()
fn()
fn怎么知道自己是被普通调用还是当做构造函数被调用了?
22.
new String('11') instanceof String //?
new String('11') instanceof Object //?
fn instanceof fn //?
23.你的项目里是怎么处理异步任务的?我说用的promise
24.在没有promise之前怎么处理异步任务?我说用回调函数
25.回调函数存在什么问题?
26.回调函数怎么解决回调地狱问题?
27.js还有哪些处理异步任务的方式
28.说一下async await
29.
async function async1() {
console.log('async1 start')
await async2()
console.log('async1 end')
}
function async2() {
console.log('async2')
}
async1()
console.log("end")
console.log('async1 start')
await async2()
console.log('async1 end')
}
function async2() {
console.log('async2')
}
async1()
console.log("end")
30.
// 假设本地机器无法做加减乘除运算,需要通过rpc远程请求让服务端来实现。
// 现有远程API的模拟实现如下:
const addRemote = async (a, b) => new Promise(resolve => {
setTimeout(() => resolve(a + b), 1000)
});
// 请实现本地的add方法,调用addRemote,能最优的实现输入数字的加法。
async function add(...inputs) {
// 你的实现
// 现有远程API的模拟实现如下:
const addRemote = async (a, b) => new Promise(resolve => {
setTimeout(() => resolve(a + b), 1000)
});
// 请实现本地的add方法,调用addRemote,能最优的实现输入数字的加法。
async function add(...inputs) {
// 你的实现
}
// 请用示例验证运行结果:
add(1, 2)
.then(result => {
console.log(result); // 3
});
add(1, 2, 2, 1, 1, 2)
.then(result => {
console.log(result); // 9
})
// 请用示例验证运行结果:
add(1, 2)
.then(result => {
console.log(result); // 3
});
add(1, 2, 2, 1, 1, 2)
.then(result => {
console.log(result); // 9
})
31.示例中的参数都是一样的,有没有什么办法可以避免多次请求
