-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlearning.log
More file actions
37 lines (28 loc) · 1.15 KB
/
Copy pathlearning.log
File metadata and controls
37 lines (28 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Learning Log
[Previous content remains unchanged...]
## JavaScript Hierarchy and Loading
Q: How does JavaScript file loading work in HTML?
A: JavaScript files are loaded and executed in the order they appear in HTML. Later scripts can override functions/variables from earlier scripts, with the last definition "winning".
Q: What is the hierarchy of JavaScript code execution?
A: The hierarchy from highest to lowest precedence is:
1. Inline JavaScript (in HTML attributes)
2. Internal JavaScript (in <script> tags)
3. External JavaScript (in separate .js files)
Example:
```html
<!-- 1. Inline JavaScript (highest) -->
<button onclick="doSomething()">Click</button>
<!-- 2. Internal JavaScript -->
<script>
function doSomething() { }
</script>
<!-- 3. External JavaScript (lowest) -->
<script src="/js/scripts.js"></script>
```
Q: How is JavaScript hierarchy different from CSS?
A: Unlike CSS which merges styles:
- JavaScript uses execution order rather than cascading
- Functions can be completely redefined
- Event listeners stack instead of overriding
- Page-specific scripts can override global scripts
[Rest of the existing content remains unchanged...]