본문으로 건너뛰기

JavaScript Summary

JavaScript Summary

JavaScript is an essential programming language in web development, acting like the brain of web pages.

Let's briefly summarize the core concepts of JavaScript.

Essential Concepts

  1. Variables: Boxes that store data.
JavaScript
let name = 'Hong Gil-dong';

  1. Functions: Blocks of code that perform specific tasks.
JavaScript
function greet(userName) {
console.log('Hello, ' + userName + '!');
}

greet('Hong Gil-dong'); // Prints "Hello, Hong Gil-dong!"

  1. Conditional Statements: Execute different code based on conditions.
JavaScript
if (name === 'Hong Gil-dong') {
console.log('Hello, Hong Gil-dong!');
} else {
console.log('Hello, guest!');
}

  1. Loops: Execute code multiple times.
JavaScript
for (let i = 0; i < 5; i++) {
console.log(i); // Prints numbers from 0 to 4.
}

  1. Objects: Collections of data with properties and values.
JavaScript
let person = {
name: 'Hong Gil-dong',
age: 25,
greet: function () {
console.log('Hello, ' + this.name + '!');
},
};

person.greet(); // Prints "Hello, Hong Gil-dong!"

  1. Events: Various incidents that occur on a web page, such as user button clicks, form submissions, and web page loads.
JavaScript
let button = document.querySelector('button');

button.addEventListener('click', function () {
alert('You clicked the button!');
});