-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ef90c26
commit a7b51c2
Showing
5 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Example using 'var' | ||
function exampleVar() { | ||
var x = 10; | ||
console.log(x); // Outputs: 10 | ||
|
||
if (true) { | ||
var x = 20; // Re-declares x | ||
console.log(x); // Outputs: 20 | ||
} | ||
|
||
console.log(x); // Outputs: 20 (var is function-scoped) | ||
} | ||
|
||
exampleVar(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Event Example</title> | ||
<script> | ||
function onSelectExample() { | ||
alert('Text has been selected!'); | ||
} | ||
|
||
function onLoadExample() { | ||
alert('Page has been loaded!'); | ||
} | ||
</script> | ||
</head> | ||
<body onload="onLoadExample()"> | ||
<h1>Event Example</h1> | ||
<textarea onselect="onSelectExample()" rows="4" cols="50"> | ||
Select some text in this area. | ||
</textarea> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Using array literal | ||
var fruits = ['apple', 'banana', 'cherry']; | ||
console.log(fruits); // Outputs: ['apple', 'banana', 'cherry'] | ||
// Using Array constructor | ||
var numbers = new Array(1, 2, 3, 4, 5); | ||
console.log(numbers); // Outputs: [1, 2, 3, 4, 5] | ||
// Using Array instance methods | ||
var moreFruits = new Array(); | ||
moreFruits[0] = 'orange'; | ||
moreFruits[1] = 'pear'; | ||
moreFruits[2] = 'grape'; | ||
console.log(moreFruits); // Outputs: ['orange', 'pear', 'grape'] |
Binary file not shown.
Binary file not shown.