File tree Expand file tree Collapse file tree 5 files changed +127
-0
lines changed
8 Jan2026 - Global and local scope Expand file tree Collapse file tree 5 files changed +127
-0
lines changed File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
6+ < title > Document</ title >
7+
8+ < script >
9+
10+ function bill ( ) {
11+
12+ tax = 190 ;
13+
14+ function calculateTax ( ) {
15+ let price = 1000 ;
16+ console . log ( tax + price ) ;
17+ }
18+
19+ calculateTax ( ) ;
20+
21+
22+ console . log ( tax ) ;
23+
24+
25+ }
26+
27+ bill ( ) ;
28+ </ script >
29+
30+ </ head >
31+ < body >
32+
33+ </ body >
34+ </ html >
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
6+ < title > Document</ title >
7+
8+ < script >
9+
10+ function bill ( ) {
11+
12+ tax = 190 ;
13+
14+ function calculateTax ( ) {
15+ let price = 1000 ;
16+ console . log ( tax + price ) ;
17+ }
18+
19+ calculateTax ( ) ;
20+
21+
22+ console . log ( tax ) ;
23+
24+
25+ }
26+
27+ bill ( ) ;
28+ </ script >
29+
30+ </ head >
31+ < body >
32+
33+ </ body >
34+ </ html >
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
6+ < title > Document</ title >
7+
8+ < script >
9+
10+
11+ const info = {
12+ name : "Alice" ,
13+ age : 30 ,
14+ city : "New York"
15+ }
16+
17+ console . log ( info . name ) ;
18+
19+ console . log ( info ) ;
20+
21+ console . log ( info [ 'age' ] ) ;
22+
23+ // get all keys
24+ console . log ( Object . keys ( info ) ) ;
25+
26+ // for loop
27+ for ( let key in info ) {
28+ console . log ( key + ": " + info [ key ] ) ;
29+ }
30+
31+ // other way
32+
33+ for ( i = 0 ; i < 3 ; i ++ ) {
34+ keys = Object . keys ( info ) [ i ]
35+ console . log ( keys + ": " + info [ keys ] ) ;
36+ }
37+
38+
39+
40+ // other example
41+
42+ const student = {
43+ firstName : "Alice" ,
44+ lastName : "Smith" ,
45+ age : 20 ,
46+ greet : function ( ) {
47+ console . log ( "this is info about student:" ) ;
48+ }
49+ } ;
50+
51+ student . greet ( ) ; // "Hello, I'm Alice Smith."
52+
53+ </ script >
54+
55+ </ head >
56+ < body >
57+
58+ </ body >
59+ </ html >
You can’t perform that action at this time.
0 commit comments