자바스크립트

21225 단어

소개



JavaScript는 웹 페이지에 혁신적인 기능을 구현할 수 있는 덜 복잡한 언어입니다. 동적 웹페이지나 웹페이지에서 상호작용하는 모든 것을 볼 때마다 그 뒤에 JavaScript가 있을 가능성이 매우 높습니다. JavaScript는 2D/3D 디자인, 시계, 주크박스 등을 만드는 데 사용할 수 있습니다!

자바스크립트 요소



자바스크립트 유형




숫자

A Number is the most straightforward type of JavaScript that can be written, it is simply just numbers that can be types into the code.



let x = 23;
console.log(x);
//Output = 23






A String is JavaScript is seen as alphabetical characters such as "John Doe" or "The Dog". It can be seen as text, but it must between a set of quotation marks or apostraphes.



let x = "Tulips";
console.log(x);
//Output = Tulips




부울

A Boolean is a type of JavaScript Value that yields as only true and false. For example "Dog" == "Cat", this returns as False.



let x = 37;
let y = 42;
let z = Boolean(x == y);
console.log(z);
//Output = "False"




물체

An Object in JavaScript is a variable that contains multiple elements, such as weight, name, color, and other descriptive modifers.



let mrGreen = {
        firstName: "Jacob",
        lastName: "Green",
        occupation: "Entrepreneur",
        age: 45,
        description: "He has a lot of connections",
        color: "green"
    };




정렬

An Array in JavaScript is a variable That acts like a list, and can contain a series of other elements such as strings, objects, or other JavaScript compnents.



let list = ["Apple", "Orange", "Banana"];
console.log(list[2])
//Output = "Banana"


자바스크립트 비교



비교는 일반적으로 부울 함수가 수행하는 작업을 수정하기 위해 부울 연산자와 함께 사용됩니다.


같지 않음(!==)

Not Equal To is one of the two simplest statements in all of Boolean operations. It is also straightforward in meaning, meaning something is not equal to another thing.



let x = Boolean(4 !== 3);
console.log(x);
//Output = True




같음(===)

Equal To is the other one of the two simplest statements in all of Boolean operations. It is also straightforward in meaning, meaning something is equal to another thing.



let x = Boolean(23 == 23);
console.log(x);
//Output = True




크거나 같음(>=)

Greater Than or Equal To is a Boolean operator that judges not only whether one number is equal to another, but also whether it is greater than it. It is also straightforward in meaning, meaning something is greater than or equal to another thing.



let x = Boolean(37 >= 23);
let y = Boolean(23 >= 23);
let z = Boolean(18 >= 23);
console.log(x + ", " + y + ", " + z);
//Output = True, True, False




작거나 같음(<=)

Less Than or Equal To is a Boolean operator that judges not only whether one number is equal to another, but also whether it is less than it. It is also straightforward in meaning, meaning something is less than or equal to another thing.



let x = Boolean(37 <= 23);
let y = Boolean(23 <= 23);
let z = Boolean(18 <= 23);
console.log(x + ", " + y + ", " + z);
//Output = False, True, True




보다 큼(>)

Greater Than is a Boolean operator that judges only whether one number greater than another.



let x = Boolean(37 > 23);
let y = Boolean(23 > 23);
let z = Boolean(18 > 23);
console.log(x + ", " + y + ", " + z);
//Output = True, False, False




보다 작음(<)

Less Than is a Boolean operator that judges only whether one number less than another.



let x = Boolean(37 < 23);
let y = Boolean(23 < 23);
let z = Boolean(18 < 23);
console.log(x + ", " + y + ", " + z);
//Output = False, False, True


자바스크립트 조건부



조건문은 일반적으로 특정 사례의 작업을 기반으로 특정 코드를 실행하는 데 사용됩니다.


만약 (만약 (){ })

The If operator executes code simply of the conditions between the brackets is met.



let x = "dog";
if (x == "dog"){
   console.log("X is equal to dog");
}
//Output = "X is equal to dog"




Else If(만약 (){ })

The Else If operator executes code only if the conditions are met within the statement's brackets, but are not met within any previous statement's brackets.



let x = "cat";
if (x == "dog"){
   console.log("X is equal to dog");
}

else if (x == "cat"{
   console.log("X is equal to cat");
}
//Output = "X is equal to cat"




그렇지 않으면 (다른 (){ })

The Else operator executes code only if no other if or else if statements are met.



let x = "parrot";
if (x == "dog"){
   console.log("X is equal to dog");
}

else if (x == "cat"){
   console.log("X is equal to cat");
}

else (){
   console.log("X is neither a dog nor a cat");
}
//Output = "X is neither a dog nor a cat"


_자바스크립트 루프



루프는 무한히 또는 조건이 충족될 때까지 계속해서 실행되는 코드 블록입니다.


For (for (문 1, 문 2, 문 3){ })

For works as a loop until at least two conditions are met. Statement one usually servers as an initial identifier, and it only run once, statement 2 is usually the statement that tells the loop to stop based on the updated value, statement 3 usually the statement that keeps being run until statement 2 is satisfied.



for (i = 0, i < 3, i++){
   console.log(i)
}
//Output = "1"
//Output = "2"
//Output = "3"




동안 ( 동안 (){ })

While is simple to understand, as long as the statement within the brackets are true, the statement will keep repeating.



while (1 == 1){
   console.log("Looping...")
}
//Output = "Looping..."
//Output = "Looping..."
//Output = "Looping..."
//This will continue infinitely

좋은 웹페이지 즐겨찾기