InterviewSolution
| 1. |
Explain The Use Of The .pushstack() Method? |
|
Answer» The pushStack() method works by ACCEPTING an array of DOM elements and pushes them into a stack. This is done so that call to methods like .end() and .andSelf are able to behave correctly. The jquery internally uses this method to keep TRACK of all the previous COLLECTIONS of jquery while using a chain traversing method. Good examples of such methods COULD be .parents() and .filter(). For example: // select some divs The pushStack() method works by accepting an array of DOM elements and pushes them into a stack. This is done so that call to methods like .end() and .andSelf are able to behave correctly. The jquery internally uses this method to keep track of all the previous collections of jquery while using a chain traversing method. Good examples of such methods could be .parents() and .filter(). For example: // select some divs |
|