会員登録(無料)
ログイン
Improve your skills, click here now!

Here are some basic concepts and features of JavaScript that you should remember

1. Variables

Variables are used to store data values.

let name = "Alice";
const age = 25;
var isStudent = true;

2. Data Types

JavaScript has several data types including:

  • String
  • Number
  • Boolean
  • Object
  • Array
  • Undefined
  • Null

3. Operators

Operators are used to perform operations on variables and values.

  • Arithmetic: +, -, *, /, %
  • Assignment: =, +=, -=, *=, /=
  • Comparison: ==, ===, !=, !==, >, <, >=, <=
  • Logical: &&, ||, !

4. Functions

Functions are blocks of code designed to perform a particular task.

function greet(name) {
return "Hello, " + name;
}

5. Conditionals

Conditional statements are used to perform different actions based on different conditions.

if (age > 18) {
console.log("Adult");
} else {
console.log("Minor");
}

6. Loops

Loops are used to execute a block of code repeatedly.

  • for loop
javascriptコードをコピーするfor (let i = 0; i < 5; i++) {
    console.log(i);
}
  • while loop
let i = 0;
while (i < 5) {
console.log(i);
i++;
}

7. Arrays

Arrays are used to store multiple values in a single variable.

let fruits = ["Apple", "Banana", "Cherry"];

8. Objects

Objects are collections of properties and methods.

let person = {
firstName: "John",
lastName: "Doe",
age: 30,
greet: function() {
console.log("Hello, " + this.firstName);
}
};

9. DOM Manipulation

JavaScript can interact with the HTML and modify its structure or content.

document.getElementById("myElement").innerHTML = "New Content";

10. Events

JavaScript can respond to user actions like clicks, mouseovers, etc.

document.getElementById("myButton").addEventListener("click", function() {
alert("Button clicked!");
});

summary

Understanding these basics will give you a strong foundation in JavaScript. As you become more comfortable, you can explore more advanced topics like asynchronous programming, closures, and ES6+ features.