Front end interview questions · selection (continuous update)


2019.04.23Given the following code, how to modify it to make the picture width 300px? Note that the following code is not modifiable

<img style="width:480px!important;”>


  • css3Zoom:

    transform(scale(0.625, 0.625));
  • js:

  • css: max-width: 300px;(I didn’t expect that…)
  • css: box-sizing: border-box; padding-left: 90px; padding-right: 90px;(I didn’t expect that…)

2019.03.22If the promise constructor is synchronous or asynchronous, what about the then method?

This is obvious,promiseConstructor issynchronizationExecutive,thenThe method isasynchronousExecuted.
I chose a slightly more complicated example from the answer:

const promise = new Promise((resolve, reject) => {
}).then(val => {

promise.then(() => {


setTimeout(function() {
//Execution result: 124536

There will be aMacro task(macrotaskSumMicro task(microtask)The order of execution of thejavascriptOfevent loop(EventLoop)。

Last dry goods: this time, thoroughly understand the JavaScript execution mechanism. Ruan Yifeng’s detailed explanation of JavaScript operation mechanism: talk about event loop again. This problem is very important
What you don’t want to see can also be seen here:

First execute a macro task (the macro task is already running when JS is running), then execute the micro task, clear the micro task queue, then execute the macro task, then execute the micro task, clear the micro task queue

Common task types:

  • Micro task (jobs): promise / Ajax / object.observe (this method has been abandoned)
  • Macro task (task): settimout / script / Io / UI rendering

2019.01.22 ['1', '2', '3'].map(parseInt) what & why ?

Answer:1, NaN, NaN

The deformation of this question:

let unary = fn => val => fn(val)
let parse = unary(parseInt)
console.log(['1.1', '2', '0.3'].map(parse))

Answer:1.1, NaN, 0


parseIntDefinition and Usage

  • parseInt()Function resolves aCharacter string, and return ainteger
  • grammar

    • parseInt(string, radix)
    • parameter describe
      string Necessary. The string to be parsed is only converted to a valid number, and the decimal point calculation is invalid.
      radix Optional. Represents the cardinality of the number to resolve. The value is between 2 and 36. If you omit the parameter or its value is 0, the number is resolved on a 10-based basis. If it starts with ‘0x’ or ‘0x’, it will be based on 16. If the parameter is less than 2 or greater than 36, parseint() returns Nan., index, arr) => {})The first parameter is the element, the second parameter is the index, and the third parameter is the currently traversed array.

The answer is coming:

parseInt('2', 1)1 is not between 2 and 36, return to Nan.
parseInt('3', 2)3 is not a valid number in binary. Nan is returned.

Give it a try:

// [10, NaN, 2, 3, 4]

Recommended Today

Some suggestions on improving query efficiency by SQL

1. If you want to use subqueries, use exists instead of in and not exists to replace not in. Because the subquery introduced by exists only tests whether there are rows that meet the specified conditions in the subquery, which is more efficient. In either case, not in is the most inefficient. Because it does […]