
海外TikTok前端面试(英文版)
TikTok front-end development
First interview
Talk about projects:
- Thecommunicationmethodusedintheproject(http,udp,rpc)
- Howtoefficiently render lists in large quantities
- Howtoupdatethemessagenotification in real time (what should I doif somethinggoes
wrong)
Talk about products:
- Whatis thedifference between overseas users and domestic users?
- Whataspects doyouthinkyouneedtoconsiderifyouaregoingoffshore?
Chat basics:
- Event loop
2、Promise - Howvueimplementsresponsiveness(both2and3say)
- Howwouldyoudesignvuex?
- Thehookfunctioninvue
Lucode:
- Implementdeepcopy
- Implementasimpletemplatereplacement
Secondinterview
- Whatnetworkprotocols haveyoubeenexposedto?
- Whatisthedifference between HTTPSandHTTPS?
- Whataresymmetricencryption andasymmetricencryptionalgorithms, what are digital
signatures, and specific business scenarios? - Commonnetworkmodels(whateachlayerdoes)
- Talk about commondatastructures(arrays, sets, maps) and corresponding business scenarios
- You mentionedmapandtalkedaboutthedifferencebetweenweakmapandmap.
- Whatarethevariants of anarray (queue, heap, stack), and how is the heapimplemented?
- Whatarethesorting algorithms (which are stable and which are unstable)?
- Manytimesweneedtoscheduletasks.Howdoyouimplementtaskscheduling?
- Haveyoulearnedaboutdatabases?Whatarerelational andnon-relational databases?
- Whatis thedifference between a relational database and a non-relational database?
- Didyouwritetheunderlyingsourcecodeofvueinyourproject?Tell meaboutyour
implementation ideas - Vueunderlyingresponsive implementation logic, why use proxy?
- IstheObject.definedPropoty used by vue2 not good?Howtodealwiththeresponseofthe
vue2 array? - Howtoimplementthediffalgorithm?
- Howdoyouimplementtheprincipleoftemplatereplacementinthesourcecodeyou
implement? - Sinceyoutalkedaboutthespecialtreatment of attributes and Properties, why?
Howtodohand-torncode(verysimple):
- Realize Self-Adaptation on both sides, fixed in the middle
- Array of flat melons and donotrepeat(usethree methods)
- Sequential traversal of binary trees
Write fast, then I’ll come back to your project
- Theplug-in system youwrote, whatisthespecific implementation of rpc communication? Tell
methedetails? - Whyuseiframandwhynotusemicrofrontend?
- Haveyouconsideredmemoryleakagewhenusingrpc+iframe?
- Iframe loading delay. Have you thought about howtooptimizethis?
- Whathaveyouachievedinthisproject? Whatdifficulties have you encountered and how have
yousolved them?
Reference answer:
- Thecommunicationmethodsusedintheproject(HTTP,UDP,RPC)
- HTTP:Suitable for communication basedontherequest/response pattern, commonlyused
in webservices andAPIcalls, and supports higher-level protocols such as REST and GraphQL. - UDP:Suitable for scenarios with high real-time requirements but low reliability
requirements, such as video LIVE, online games, etc. Because it does not guarantee reliable
delivery of messages. - RPC(RemoteProcedureCall): makescalling remote services like calling local services,
usually used in microservice structures, common implementations are gRPC, Thrift, etc.
- Howtoefficiently render lists in large quantities
Rendering lists efficiently in large quantities is a common problem in front-end development,
especially when dealing with large amounts of data. Directly rendering all items can lead to
performance issues and poorUserExperience. Here are afewcommonandeffectivewaysto
achieve high-volume rendering lists efficiently:
1. Virtual Scrolling
Virtual scrolling improves performance by rendering only list items within the user’s viewport.
List items are dynamically loaded and unloaded as theuserscrolls.
- Implementation principle: As the user scrolls, calculate which items should be rendered and
which itemscanbeuninstalled. - Library support: such as React Virtualized, Vue Virtual Scroll List.
function VirtualizedList({ items }) {const rowRenderer = ({ index, key, style |
2. Lazy Loading
Lazy loading refers to loading new list items only when the user scrolls to a certain position,
avoiding loading all the data at once.
- Implementation principle: Listen for scrolling events and load more data as the user
approaches the bottom. - Library support: such as React Infinite Scroll, Vue Infinite Loading.
function InfiniteList({ items, fetchMoreData }) {return |
3. Pagination
Paging load is to divide the data into multiple pages, and the user needs to load the next pageof
data through the pagingcontrol.
- Implementation principle: Load the data on the next page through paging controls or infinite
scrolling. - Library support: Front-end libraries typically provide built-in paging support, such as Ant
Design’s Pagination.
function PaginatedList({ items, currentPage, onPageChange }) {const pageSize = |
4. Server-side rendering (SSR)
Server-side rendering can generate HTML on the server side, reducing client rendering pressure
wheninitially loaded.
- Implementation principle: Data and templates are rendered as HTML ontheserverside and
then sent to theclient. - Library support: such as Next.js (React) and Nuxt.js (Vue).
return { props: { items } }; |
5. Batch Updates
Batch updates improveperformancebyreducingthenumberofDOMoperations,combining
multiple updates into one.
- Implementation principle: Use the framework’s batch update mechanism, or manually
mergemultiple updateoperations. - Library support: React unstable_batchedUpdates
function updateItems(items) {unstable_batchedUpdates(() => { |
本文是原创文章,采用CC BY-NC-SA 4.0协议,完整转载请注明来自MaxKin's Blogs