答
筆試內容跟其他人分享差不多 十個問答 跟 兩個coding
var arr = []; What is the result of "typeof arr"? = Object
The output of the following code is?
var val = 'smtg';
console.log('Value is ' + (val === 'smtg') ? 'Something' : 'Nothing'); = 'Something'
What happens if shift is applied to [1,2,3,4,5] ? = [2,3,4,5]
CSS style, margin: 10px 20px 40px 30px; What is the bottom margin? = top right bot left 40px
In JavaScript, the method used to prevent the default action of the default event is?
preventDefault()
explain why null == undefined is True
How to define inline styles in html elements? = Style
The <td> tag in HTML is used to define? = a cell in table
In ECMAScript6, which item does not belong to the promise state? = Pause
push, concat, sort, shift, which of these does not change the original array? = concat
筆試通過的話會再約二面 一樣是線上 跟工程師
問題主要圍繞自我介紹跟前端相關技術
解釋CSS, flex, grid
如何自行封裝axios?
會不會 binary search?
面試問答
Given an array of integer numbers. The unique elements in an array are those that appear exactly once. Return the sum of unique elements in the array.
function sumOfUnique(nums) {
const countMap = new Map();
for (let num of nums) {
countMap.set(num, (countMap.get(num) || 0) + 1);
}
let sum = 0;
for (let [num, count] of countMap.entries()) {
if (count === 1) {
sum += num;
}
}
return sum;
}
Given an array of integers. find the length of the longest continuous increasing subsequence and return it.
function longestIncreasingSubsequence(nums) {
if (nums.length === 0) return 0;
let maxLength = 1;
let currentLength = 1;
for (let i = 1; i < nums.length; i++) {
if (nums[i] > nums[i - 1]) {
currentLength++;
maxLength = Math.max(maxLength, currentLength);
} else {
currentLength = 1;
}
}
return maxLength;
}
Given an unsorted array of integers, find the length of the longest continuous increasing subsequence and return it. eg: [1,3,2,4,6,3,2,4,5,6,7,3,8] => [2,4,5,6,7]