高级农民
- 积分
- 1193
- 大米
- 颗
- 鳄梨
- 个
- 水井
- 尺
- 蓝莓
- 颗
- 萝卜
- 根
- 小米
- 粒
- 学分
- 个
- 注册时间
- 2019-3-11
- 最后登录
- 1970-1-1
|
2019(4-6月) FrontEndEng 本科 实习@阿里巴巴 - 网上海投 - 技术电面 Onsite | Fail | 其他
注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
1. 前端常见跨域解决方案. Waral dи,
1、 通过jsonp跨域
2、 document.domain + iframe跨域. Χ
3、 location.hash + iframe
4、 window.name + iframe跨域
5、 postMessage跨域
6、 跨域资源共享(CORS)
7、 nginx代理跨域
8、 nodejs中间件代理跨域
9、 WebSocket协议跨域
. Χ
2.你提到了jsonp,它和json的区别是什么
其实json和jsonp本质上都是字符串,只是jsonp是外层包裹了一层函数。
jsonp的原理就是通过script的src,将函数作为src请求地址的参数来传递数据,所以jsonp只有get一种传输方式。.
下面是jsonp的数据交互,首先定义一个回调函数,定义dataType类型为jsonp,将函数作为参数传输给后台,它与json相比是多了一层函数。
. 1point3acres
3。如何知道jsonp后端的函数返回了?
就答了addeventlistener,然后面试官问还有别的吗,我说不知道,然后被科普了正则运算。。
..
4.前端里怎么添加类名:
. Χ
- select.classlist.add("xxx")
复制代码 follow-up 还有其他的吗?
- var classVal = document.getElementById("id").getAttribute("class");
- .1point3acres
- //删除的话
- classVal = classVal.replace("someClassName","");
- document.getElementById("id").setAttribute("class",classVal );
- //添加的话
- classVal = classVal.concat(" someClassName");
- document.getElementById("id").setAttribute("class",classVal );
复制代码
5.能不能添加一个功能,没有这个class的时候再加呢
- if($('div').is('.class')){
- $('div').addClass('class');
- }
复制代码
还有吗?
- if (!p.classList.contains('classname')) {
- p.className += ' ' + 'classname';
- }
复制代码 . .и
. 1point3acres.com
6.css垂直居中和水平居中
- 第一种. From 1point 3acres bbs
- #container{
- position:relative;
- }
-
- #center{
. Χ - width:100px;
- height:100px;
- position:absolute;
- top:50%;
- left:50%;
- transform: translate(-50%,-50%);. check 1point3acres for more.
- }
-
- 第二种
- #container{
- position:relative;
- }
-
- #center{. check 1point3acres for more.
- width:100px;. Χ
- height:100px;. 1point3acres.com
- position:absolute;
- top:50%;
- left:50%;. 1point3acres
- margin:-50px 0 0 -50px;
- }
-
- 第三种
- #container{
- position:relative;
- }.google и
-
- #center{
- position:absolute;
- margin:auto;
- top:0;
- bottom:0;. Χ
- left:0;. From 1point 3acres bbs
- right:0;
- }
- . 1point3acres.com
- 第四种 flex
- #container{
- display:flex;
- justify-content:center;
- align-items: center;
. 1point 3 acres - }
-
复制代码 .1point3acres
7.怎么使一个边框有两种颜色?. 1point3acres
这题不会。。。到最后都没听懂什么意思,我说用border double,他问怎么double,我说没用过不知道。 8.嵌套的数组扁平化(多维数组变成一维数组)
- function parseArr(arr,res){.google и
- var i=0;. check 1point3acres for more.
- for(i=0;i<arr.length;i++){
- if(arr[i] instanceof Array){
- parseArr(arr[i],res);.--
- }else{
- res.push(arr[i]);
- }
- }. 1point 3 acres
- }
复制代码
- var newArr=arr.toString().split(',').map(function(ele){
- return +ele;-baidu 1point3acres
- });
复制代码
9.你提到了tostring(),为什么它可以把数组扁平化
真不知道,除了mdn上写tostring就是把所有object变成字符串
10.你简历上的一个网站怎么做移动端适配的?
对不起我没做这个。
11.用过react和vue吗?
没有,在谷歌实习用的polymer
12.google chrome怎么做测试的?
。。。一系列实习相关问题。。
最后被拒了,最迷的是被拒没有邮件,需要自己去系统查。
move on了。
补充内容 (2019-6-16 23:09):. Χ
我都挂了可怜我打了这么多代码加个米吧!!谢谢谢谢 |
上一篇: 阿里巴巴 电面 一面面经下一篇: Airbnb 北京onsite
|