攜程筆試總體上還算簡單,但是自己對于一些問題理解還不夠深入,所以導致在做題的時候還是有點蒙蔽,下面貼出自己記得住的題目。試題分為兩部分,第一大題是選擇器20道40分,第二大題是編程題三道60分
題型: JS基礎,前端基礎, java基礎, 數(shù)據(jù)庫基礎
一、選擇題
1.下列不能歸為一類的是
A.SVG,WebGl,MPEG
B.tr, i, p
C.TypeScript, postcss, jade
2.關(guān)于promise,輸出結(jié)果( A )
new Promise( ()=>{ console.log(1) }).then( ()=>{ console.log(2) })
console.log(3)
A.1 3
B.1 2
C.1 3 2
D.1 2 3
3下列關(guān)于修飾符混用的說法,錯誤的是(D)
A.a(chǎn)bstract不能與final并列修飾同一個類
B.a(chǎn)bstract類中不可以有private的成員
C.a(chǎn)bstract方法必須在abstract類中
D.static方法中能處理非static的屬性
4.java String A = 'abc'
int B[] = [1, 2,3]
獲取長度正確的是( A )
a.A.length()
b.A.length
c.B.length()
d.B.length
5.下列關(guān)于聚合函數(shù)正確的是( C )
A.SUM( * )
B.MAX( * )
C.COUNT( * )
D.AVG( * )
6.下列關(guān)于TRUNCATE TABLE說法正確的是( A)
A.可以有選擇性的截斷表中的數(shù)據(jù)
B.可以無條件的刪除form
C.作用等于DROP FORM
7.狀態(tài)碼錯誤的是( D )
A.100 continue
B 200 ok
C 500 Internet server error
D 302 Moved persistent(永久重定向)
分析:301表示永久重定向(Moved persistent)
302表示臨時重定向(Moved temporary)
8.javascript的typeof不會返回以下類型( B )
A.undefined
B.array
C.function
D.object
分析:typeof返回的類型有七種: null、undedined、boolean、string、object、symbol、function
9.下列關(guān)于fetch一定不正確的是()
fetch.get({
url:'www.baidu.com',
methods:' get'
cache: true,
header-request: '...'
}).then( (res)=>{ console.log(res) })
A.methods支持get,post,delete,options
B.當服務器返回500,代碼會報錯
C.在瀏覽器控制臺運行會報錯
D.兼容性問題
10.結(jié)果輸出(A)
var foo = 1
funtion foo(){
console.log(foo)
}
foo()
A.error
B.1
C.undefined
分析:變量聲明和函數(shù)聲明同時存在提升,所以代碼等同于
var foo
function foo( ){
console.log(foo)
}
foo = 1
foo()
最后運行報錯foo is not a function
11.js代碼輸出( C )
var x = 1
function foo(){
x++
this.x == x
return function(){
console.log(x)
}
}
var a = 2
var obj = new foo()
obj(a)
A.error
B.1
C.2
D.undefined
12.給出代碼,判斷設計模式:單例模式,工廠構(gòu)造模式,適配器模式
二、編程題
1.正則表達式
輸入 攜程C2t0r1i8p2020校招
輸出 2018Ctrip
使用正則表達式截取數(shù)字和字符串,并且字符串位于數(shù)字后面
var str = readline()
var nums = str.match(/\d+/g)
var chars = str.match(/[A-Za-z]/g)
nums = Array.from(new Set(nums))
print(nums.slice(0, nums.length-1).concat(chars).join(''))
2數(shù)組升維

3.現(xiàn)類似迭代方法中的map()方法
輸入
[1, 2, 3, 4]
{a: 1, b: 'test'}
輸出
[{"key":0,"value":1},{"key":1,"value":2},{"key":2,"value":3},{"key":3,"value":4}]
{"a":{"key":"a","value":1},"b":{"key":"b","value":"test"}}
要求:當輸入[]、{}、字符串等返回null
/******************************開始寫代碼******************************/
function map(data, fn) {
//判斷data類型是數(shù)組還是對象
if(Object.prototype.toString.call(data) === '[object Array]'){
var res = []
data.map(function(index, val, array){
res.push(fn(index, val))
})
return res
}else if(Object.prototype.toString.call(data) === '[object Obejct]'){
var res = {}
for(let key in data){
res[key] = fn(key,val)
}
return res
}
// {} '' nuber等
return null
}
/******************************結(jié)束寫代碼******************************/
var input = readline();
var data = JSON.parse(input);
var result = map(data, function(value, key) {
return {
key: key,
value: value,
}
});
print(JSON.stringify(result));
