当前位置:网站首页>Niuke JS wrong question knowledge point record

Niuke JS wrong question knowledge point record

2022-06-11 07:51:00 AQ14_

plus + The definition of

about “+” Come on , There are two meanings : The first meaning is string splicing , The second meaning is addition in addition and subtraction .
1, If one of the operands is a string , Other values will be converted to strings ;
2, Other situations , Operands are converted into numbers to perform addition operations .
And for “ - ” Come on , There is only one meaning , It's subtraction , Naturally, it will not be converted into a string .

web Page lifecycle

The loading sequence of general browsers is as follows :

  • script executed
  • readyState : interactive
  • DOMContentLoaded
  • image onload
  • iframe onload
  • readyState : complete
  • window onload

summary :

  • synchronous JavaScript Script executes first , It precedes DOMContentLoaded Event to perform .

  • When DOM When ready ,DOMContentLoaded The incident happened in document Trigger on . Can be used at this stage JavaScript To operate DOM Elements .

      All scripts have been executed , Except for those external uses of asynchrony (async) Or delay (defer) Loaded script 
      Images and other resources may still be loading .
    
  • window Upper onload event , Trigger after all resources are loaded on the page . Most of the operations we should put in DOMContentLoaded In the event , Instead of putting it in window.onload In the implementation of , Because the usual operations don't have to wait until the end .

  • window Upper beforeunload event , This event occurs when the user is ready to leave the page , stay unload Triggered before the event . If beforeunload Returns a string , The browser will give a prompt whether the user really wants to leave .

  • window Upper unload event , This event will be triggered when the user finally leaves . stay unload In the event handler of , We can only do simple things , It does not involve delaying or asking the user . Because of this limitation , It's rarely used .

  • document.readyState Indicates the current status of the document , Can be in readystatechange Event to track changes in document status .

     loading –  Document loading .
     interactive – document Triggered when the resolution has been completed , Almost DOMContentLoaded At the same time , But in DOMContentLoaded Triggered before the event .
     complete –  Triggered when the document and resources are loaded , Almost window.onload At the same time , But in onload Triggered before the event .
    

Factors leading to backflow

  1. Resize window , Browser window size changed ——resize Event time
  2. Element size change —— Margin 、 fill 、 Frame 、 Width and height ; Change font size
  3. Page rendering initialization
  4. Element position changes
  5. Style sheet changes
  6. Element content changes , Especially the input control
  7. CSS Pseudo class activation
  8. DOM operation , Add or remove visible DOM Elements
  9. offsetWidth, width, clientWidth, scrollTop/scrollHeight The calculation of ,
    Will cause the browser to gradually return to the queue Flush, Perform backflow immediately .
  10. Content change —— For example, the width and height of the calculation value caused by the change of the text or the size of the picture
原网站

版权声明
本文为[AQ14_]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203020516591931.html