
??????? ??????
JavaScript? ????? ????? ???? ??? ? ??? ?? ????? ?????. HTML? ???? ???? ???? ? ???? CSS? ???? ???? ? ???? ??, JavaScript? ??? ???? ????? ??? ??? ??? ? ??? ????.
?:
? ??? ???? ?? ?? ?????(?: ?? ??).
? ????? ???? ???? ?????.
? ??? ?? ?? ?? ??(??? ?? ?)? ?????.
JavaScript? ?? ??(??)
- ?????? ??: JavaScript? Chrome, Firefox, Safari? ?? ?????? ?? ????? ?? ?? ?? ?????.
- ??: ????? ?? ???? ??? ????(??? ?? ??)? ??? ? ????.
- ???: ??, ??? ???, ? ???? ?? ???? ?????.
- ??: ?????? ?? ???? ??? ??? ?????.
- ???? ??: JavaScript? ????(?????)? ??(???, Node.js ??) ???? ?????.
JavaScript ?? ??(???)
????? ??? ?:
- JavaScript ??: ????? HTML ? CSS? ?? JavaScript ??? ?????.
- ?? ??: ????? JavaScript ??(?: Chrome? V8)? JavaScript? ? ?? ?????.
- ???? ????: JavaScript? ??? ?? ???? ??? ????? ??? ? ????.
- ?? ?? ?? ??.
- ???? ?? ???? ???? ?????.
- ??? ??? ?? ???? ????? ????.
??? ??? ?? ??
???? ??? ??
??? ?? JavaScript? ??? ???? ???? ???? ??? ?????.
<!DOCTYPE html>
<html lang="en">
<head>
<title>JavaScript Example</title>
</head>
<body>
<h1>
<p>Explanation:</p>
- The getElementById("heading") selects the 'h1' element.
- .innerText = "Hello, JavaScript!"; changes its text.
Button Click Example
You can make a button do something when clicked.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Click Example</title>
</head>
<body>
<button>
<p>What Happens:</p>
- The button listens for a “click.”
- When clicked, JavaScript updates the
tag with a message.
Simple Calculator
Let’s create a calculator for adding two numbers.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Simple Calculator</title>
</head>
<body>
<input type="number">
<p>How It Works:</p>
- The user enters numbers in two input fields.
- When the “Add” button is clicked, JavaScript calculates the sum and displays it.
Key Concepts in JavaScript
Variables:
Variables store data that can be used later.
Why Use Variables?
Variables help you:
- Store Information: Keep data in memory for later use.
- Reuse Values: Avoid rewriting the same value multiple times.
- Make Code Dynamic: Change variable values to alter program behavior.
let name = "John"; // Storing the value "John" in a variable called name
console.log(name); // Outputs: John
??:
JavaScript?? ???
???? ??? ??? ??? ?? ?????.
?? ??? ?????. ?? ?? ??? ??? ? ????
? ? ???? ?? ? ???? ??? ? ?????
??????.
function greet(name) {
return "Hello, " + name;
}
console.log(greet("Alice")); // Output: Hello, Alice
console.log(greet("Bob")); // Output: Hello, Bob
*???: *
JavaScript? ???? ?????? ???? ?? ?? ????, ?? ???? ?? ??????(?: ?? ??, ?? ??? ?? ?? ? ?? ??). JavaScript? ??? ???? "??"?? ?? ?? ???? ?? ??? ??? ? ????. ?? ???? ?? ????? ??? ?? ?? ?????.
<!DOCTYPE html>
<html lang="en">
<head>
<title>JavaScript Example</title>
</head>
<body>
<h1>
<p>Explanation:</p>
- The getElementById("heading") selects the 'h1' element.
- .innerText = "Hello, JavaScript!"; changes its text.
Button Click Example
You can make a button do something when clicked.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Click Example</title>
</head>
<body>
<button>
<p>What Happens:</p>
- The button listens for a “click.”
- When clicked, JavaScript updates the
tag with a message.
Simple Calculator
Let’s create a calculator for adding two numbers.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Simple Calculator</title>
</head>
<body>
<input type="number">
<p>How It Works:</p>
- The user enters numbers in two input fields.
- When the “Add” button is clicked, JavaScript calculates the sum and displays it.
Key Concepts in JavaScript
Variables:
Variables store data that can be used later.
Why Use Variables?
Variables help you:
- Store Information: Keep data in memory for later use.
- Reuse Values: Avoid rewriting the same value multiple times.
- Make Code Dynamic: Change variable values to alter program behavior.
let name = "John"; // Storing the value "John" in a variable called name
console.log(name); // Outputs: John
??:
JavaScript?? ??? ?? ??? ?? ? ???? ? ?????. ??? ??? ????? ??? ??? ??? ??? ???? ? ?? ?? ??? ??? ?? ? ????? ??? ?????.
JavaScript?? ??? ??? ??? ?? ??? ??? ????. ?? ???? ?? ???????
for ??? ?? ???? ?????. ??? ???? ?? ??? ?????.
function greet(name) {
return "Hello, " + name;
}
console.log(greet("Alice")); // Output: Hello, Alice
console.log(greet("Bob")); // Output: Hello, Bob
??? ??? true? ?? while ??? ?????. ? ?? ?? ??? ?????.
<button>
<p><strong>Conditions:</strong><br>
In JavaScript, conditions are used to perform different actions <br>
based on whether a specified condition evaluates to true or false. <br>
This helps control the flow of your program, allowing it to make <br>
decisions.</p>
<p>Why Use Conditions?</p>
<ul>
<li>Decision Making: Execute code based on specific situations.</li>
<li>Dynamic Behavior: React to user input or external data.</li>
<li>Error Handling: Handle unexpected cases gracefully.
</li>
</ul>
<pre class="brush:php;toolbar:false">let age = 20;
if (age >= 18) {
console.log("You are an adult.");
} else {
console.log("You are not an adult.");
}
do...while ??? while ??? ????? ??? ??? false? ???? ??? ??? ? ? ????? ?? ?????. ? ?? ?? ??? ?????.
// Print numbers 1 to 5
for (let i = 1; i <= 5; i++) {
console.log(i);
}
// Output: 1, 2, 3, 4, 5
for...in ??? ??(?)? ??? ???? ? ?????.
// Print numbers 1 to 5 using a while loop
let i = 1;
while (i <= 5) {
console.log(i);
i++; // Don't forget to increment i!
}
// Output: 1, 2, 3, 4, 5
for...of ??? ?? ??? ??(?: ??, ??? ?? ?? ?? ??? ??)? ?? ???? ? ?????.
// Print numbers 1 to 5 using do...while loop
let i = 1;
do {
console.log(i);
i++;
} while (i <= 5);
// Output: 1, 2, 3, 4, 5
JavaScript? ???? ?
- ????? ??:
React, Angular ? Vue.js? ?? JavaScript ?????? ??? ?? ? ?????.
??? ????? ?????.
- ??? ??:
Node.js? ???? JavaScript? ???? ???? ??? ??? ??? ? ????.
- API:
JavaScript? ?? ???? ???? ?????.
? ??????? ??? ????
- ?? ???: ?? ?? ?????? JavaScript? ?????.
- ?? ??: ? ????? ?????.
- ?? ??: JavaScript? ???? ?????? ????? ??? ???.
??
JavaScript? ????? ?????? ??? ????? ?????.
??? ??? ???? ?? ??? ????
???? ???? ?? ??? ??? ??? ? ????
?????!
? ??? JavaScript? ?? ??: ? ?? ???? ?? ???? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!