|
4 | 4 |
|
5 | 5 | **Browser has JS Engine which has Call Stack which has Global exec context, local exec context etc**
|
6 | 6 | - But browser has many other *superpowers* - Local storage space, Timer, place to enter URL, Bluetooth access, Geolocation access and so on
|
7 | | -- Now JS needs some way to connect the callstack with all these superpowers. |
| 7 | +- Now JS needs some way to connect the callstack with all these superpowers. This is done using **Web APIs** |
| 8 | + |
| 9 | +### WebAPIs |
| 10 | +None of the below are part of Javascript! These are extra superpowers that browser has. Browser gives access to JS callstack to use these powers. |
| 11 | +> setTimeout(), DOM APIs, fetch(), localstorage, console (yes, even console.log is not JS!!), location and so many more.. |
| 12 | + |
| 13 | +- setTimeout() : Timer function |
| 14 | +- DOM APIs : eg.Document.xxxx ; Used to access HTML <html><script><body>..... DOM tree. (Document Object Manipulation) |
| 15 | +- fetch() : Used to make connection with external servers eg. Netflix servers etc. |
| 16 | + |
| 17 | +We get all these inside call stack through *global object* ie. **window** |
| 18 | +- Use window keyword like : window.setTimeout(), window.localstorage, window.console.log() to log something inside console. |
| 19 | +- As window is global obj, and all the above functions are present in global object, we don't explicity write *window* but it is implied |
| 20 | + |
| 21 | + |
| 22 | + |
8 | 23 |
|
0 commit comments