Presented by Swapnil Meshram within mentorship @devsyncin
π Started learning JavaScript with the guidance of @devsyncin with focused on basics concepts such as javascript variables, loops, with simple hands-on practice.
π 1. What is JavaScript?
JavaScript is a high-level, interpreted programming language used to create dynamic and interactive effects on websites.
πΉ Runs in the browser
πΉ Client-side scripting (can also be used on the server with Node.js)
πΉ Lightweight and versatile
π 2. How to Add JavaScript
You can include JavaScript in three main ways:
<!-- Inline JavaScript -->
<button onclick="alert('Hello!')">Click Me</button>
<!-- Internal JavaScript -->
<script>
alert("Hello from internal JS!");
</script>
<!-- External JavaScript -->
<script src="script.js"></script>
π 3. Variables
Variables are containers for storing data.
var name = "John"; // old way
let age = 25; // modern way
const country = "India"; // constant value
π 4. Data Types
JavaScript supports different data types:
String β "Hello"
Number β 123, 3.14
Boolean β true or false
Object β { key: value }
Array β [1, 2, 3]
Null β null
Undefined β undefined
π 5. Operators
Some basic operators:
+ // addition
- // subtraction
* // multiplication
/ // division
% // modulus
== // equal value
=== // equal value and type
!= // not equal
> // greater than
< // less than
π 6. Conditional Statements
Used to perform different actions based on conditions.
let score = 90;
if (score >= 90) {
console.log("Excellent");
} else if (score >= 70) {
console.log("Good");
} else {
console.log("Try again");
}
π 7. Loops
Loops run a block of code multiple times.
// for loop
for (let i = 0; i < 5; i++) {
console.log(i);
}
// while loop
let i = 0;
while (i < 5) {
console.log(i);
i++;
β Summary
JavaScript allows you to:
Add interactivity (buttons, sliders)
Handle user input and events
Modify the webpage dynamically
Top comments (0)