JS Reference

JS by Category JS by Alphabet

JavaScript

JS Array JS Boolean JS Classes JS Date JS Error JS Global JS JSON JS Math JS Number JS Operators JS RegExp JS Statements JS String

Window

Window Object Window Console Window History Window Location Window Navigator Window Screen

HTML DOM

DOM Document DOM Element DOM Attributes DOM Events DOM Event Objects DOM HTMLCollection DOM Style
alignContent alignItems alignSelf animation animationDelay animationDirection animationDuration animationFillMode animationIterationCount animationName animationTimingFunction animationPlayState background backgroundAttachment backgroundColor backgroundImage backgroundPosition backgroundRepeat backgroundClip backgroundOrigin backgroundSize backfaceVisibility border borderBottom borderBottomColor borderBottomLeftRadius borderBottomRightRadius borderBottomStyle borderBottomWidth borderCollapse borderColor borderImage borderImageOutset borderImageRepeat borderImageSlice borderImageSource borderImageWidth borderLeft borderLeftColor borderLeftStyle borderLeftWidth borderRadius borderRight borderRightColor borderRightStyle borderRightWidth borderSpacing borderStyle borderTop borderTopColor borderTopLeftRadius borderTopRightRadius borderTopStyle borderTopWidth borderWidth bottom boxShadow boxSizing captionSide caretColor clear clip color columnCount columnFill columnGap columnRule columnRuleColor columnRuleStyle columnRuleWidth columns columnSpan columnWidth counterIncrement counterReset cursor direction display emptyCells filter flex flexBasis flexDirection flexFlow flexGrow flexShrink flexWrap cssFloat font fontFamily fontSize fontStyle fontVariant fontWeight fontSizeAdjust height isolation justifyContent left letterSpacing lineHeight listStyle listStyleImage listStylePosition listStyleType margin marginBottom marginLeft marginRight marginTop maxHeight maxWidth minHeight minWidth objectFit objectPosition opacity order orphans outline outlineColor outlineOffset outlineStyle outlineWidth overflow overflowX overflowY padding paddingBottom paddingLeft paddingRight paddingTop pageBreakAfter pageBreakBefore pageBreakInside perspective perspectiveOrigin position quotes resize right scrollBehavior tableLayout tabSize textAlign textAlignLast textDecoration textDecorationColor textDecorationLine textDecorationStyle textIndent textOverflow textShadow textTransform top transform transformOrigin transformStyle transition transitionProperty transitionDuration transitionTimingFunction transitionDelay unicodeBidi userSelect verticalAlign visibility width wordBreak wordSpacing wordWrap widows zIndex

Web APIs

API Console API Fullscreen API Geolocation API History API MediaQueryList API Storage

HTML Objects

<a> <abbr> <address> <area> <article> <aside> <audio> <b> <base> <bdo> <blockquote> <body> <br> <button> <canvas> <caption> <cite> <code> <col> <colgroup> <datalist> <dd> <del> <details> <dfn> <dialog> <div> <dl> <dt> <em> <embed> <fieldset> <figcaption> <figure> <footer> <form> <head> <header> <h1> - <h6> <hr> <html> <i> <iframe> <img> <ins> <input> button <input> checkbox <input> color <input> date <input> datetime <input> datetime-local <input> email <input> file <input> hidden <input> image <input> month <input> number <input> password <input> radio <input> range <input> reset <input> search <input> submit <input> text <input> time <input> url <input> week <kbd> <label> <legend> <li> <link> <map> <mark> <menu> <menuitem> <meta> <meter> <nav> <object> <ol> <optgroup> <option> <output> <p> <param> <pre> <progress> <q> <s> <samp> <script> <section> <select> <small> <source> <span> <strong> <style> <sub> <summary> <sup> <table> <tbody> <td> <tfoot> <th> <thead> <tr> <textarea> <time> <title> <track> <u> <ul> <var> <video>

Other References

CSSStyleDeclaration JS Conversion


JavaScript 연산자 참조


JavaScript 연산자는 값을 할당하고, 값을 비교하고, 산술 연산을 수행하는 등의 작업에 사용됩니다.


JavaScript 산술 연산자

산술 연산자는 변수 및/또는 값 사이의 산술을 수행하는 데 사용됩니다.

y = 5 인 경우 아래 표는 산술 연산자를 설명합니다.

Operator Description Example Result in y Result in x Try it
+ Addition x = y + 2 y = 5 x = 7
- Subtraction x = y - 2 y = 5 x = 3
* Multiplication x = y * 2 y = 5 x = 10
/ Division x = y / 2 y = 5 x = 2.5
% Modulus (division remainder) x = y % 2 y = 5 x = 1
++ Increment x = ++y y = 6 x = 6
x = y++ y = 6 x = 5
-- Decrement x = --y y = 4 x = 4
x = y-- y = 4 x = 5

산술 연산자에 대한 자습서는 JavaScript 산술 자습서 를 읽으십시오 .


JavaScript 할당 연산자

할당 연산자는 JavaScript 변수에 값을 할당하는 데 사용됩니다.

x = 10y = 5 인 경우 아래 표는 할당 연산자를 설명합니다.

Operator Example Same As Result in x Try it
= x = y x = y x = 5
+= x += y x = x + y x = 15
-= x -= y x = x - y x = 5
*= x *= y x = x * y x = 50
/= x /= y x = x / y x = 2
%= x %= y x = x % y x = 0

할당 연산자에 대한 자습서는 JavaScript 할당 자습서 를 읽으십시오 .



JavaScript 문자열 연산자

+ 연산자 및 += 연산자를 사용하여 문자열을 연결(추가)할 수도 있습니다.

text1 = "Good " , text2 = "Morning" 및 text3 = ""경우 아래 표는 연산자를 설명합니다.

Operator Example text1 text2 text3 Try it
+ text3 = text1 + text2 "Good " "Morning"  "Good Morning"
+= text1 += text2 "Good Morning" "Morning" ""

비교 연산자

비교 연산자는 논리문에서 변수 또는 값 간의 같음 또는 차이를 결정하는 데 사용됩니다.

x = 5 인 경우 아래 표는 비교 연산자를 설명합니다.

Operator Description Comparing Returns Try it
== equal to x == 8 false
x == 5 true
=== equal value and equal type x === "5" false
x === 5 true
!= not equal x != 8 true
!== not equal value or not equal type x !== "5" true
x !== 5 false
> greater than x > 8 false
< less than x < 8 true
>= greater than or equal to x >= 8 false
<= less than or equal to x <= 8 true

비교 연산자에 대한 자습서는 JavaScript 비교 자습서 를 읽으십시오 .


조건부(삼항) 연산자

조건 연산자는 조건에 따라 변수에 값을 할당합니다.

Syntax Example Try it
variablename = (condition) ? value1:value2 voteable = (age < 18) ? "Too young":"Old enough";

예 설명: 변수 "age"가 18 미만이면 "voteable" 변수의 값은 "Too young"이 되고, 그렇지 않으면 voteable의 값은 "Old 충분히"가 됩니다.


논리 연산자

논리 연산자는 변수 또는 값 간의 논리를 결정하는 데 사용됩니다.

x = 6 및 y = 3 인 경우 아래 표는 논리 연산자를 설명합니다.

Operator Description Example Try it
&& and (x < 10 && y > 1) is true
|| or (x === 5 || y === 5) is false
! not !(x === y) is true

JavaScript 비트 연산자

비트 연산자는 32비트 숫자에서 작동합니다. 연산의 모든 숫자 피연산자는 32비트 숫자로 변환됩니다. 결과는 JavaScript 번호로 다시 변환됩니다.

Operator Description Example Same as Result Decimal
& AND x = 5 & 1 0101 & 0001 0001  1
| OR x = 5 | 1 0101 | 0001 0101  5
~ NOT x = ~ 5  ~0101 1010  10
^ XOR x = 5 ^ 1 0101 ^ 0001 0100  4
<< Left shift x = 5 << 1 0101 << 1 1010  10
>> Right shift x = 5 >> 1 0101 >> 1 0010   2

위의 예는 4비트의 부호 없는 예를 사용합니다. 그러나 JavaScript는 32비트 부호 있는 숫자를 사용합니다.

이 때문에 JavaScript에서 ~ 5는 10을 반환하지 않고 -6을 반환합니다.

~0000000000000000000000000000101 1111111111111111111111111111010을 반환합니다


typeof 연산자

typeof 연산자는 변수, 객체, 함수 또는 표현식의 유형을 반환합니다 .

예시

typeof "John"                 // Returns string
typeof 3.14                   // Returns number
typeof NaN                    // Returns number
typeof false                  // Returns boolean
typeof [1, 2, 3, 4]           // Returns object
typeof {name:'John', age:34}  // Returns object
typeof new Date()             // Returns object
typeof function () {}         // Returns function
typeof myCar                  // Returns undefined (if myCar is not declared)
typeof null                   // Returns object

다음 사항을 준수하십시오.

  • NaN의 데이터 유형은 숫자입니다.
  • 배열의 데이터 유형은 객체입니다.
  • 날짜의 데이터 유형은 객체입니다.
  • null의 데이터 유형은 객체입니다.
  • 정의되지 않은 변수의 데이터 유형이 정의되지 않았습니다.

JavaScript 객체가 배열(또는 날짜)인지 정의하기 위해 typeof 를 사용할 수 없습니다 .


삭제 연산자

삭제 연산자 는 객체에서 속성을 삭제합니다.

예시

const person = {
  firstName:"John",
  lastName:"Doe",
  age:50,
  eyeColor:"blue"
};
delete person.age;   // or delete person["age"];

삭제 연산자는 속성 값과 속성 자체를 모두 삭제합니다.

삭제 후에는 속성을 다시 추가하기 전에는 사용할 수 없습니다.

삭제 연산자는 개체 속성에 사용하도록 설계되었습니다. 변수나 함수에는 영향을 미치지 않습니다.

참고: 사전 정의된 JavaScript 개체 속성에는 삭제 연산자를 사용하면 안 됩니다. 응용 프로그램이 충돌할 수 있습니다.


인 연산자

in 연산자 는 지정된 속성이 지정된 객체에 있으면 true를 반환하고 그렇지 않으면 false를 반환합니다.

예시

// Arrays
const cars = ["Saab", "Volvo", "BMW"];
"Saab" in cars          // Returns false (specify the index number instead of value)
0 in cars               // Returns true
1 in cars               // Returns true
4 in cars               // Returns false (does not exist)
"length" in cars        // Returns true  (length is an Array property)

// Objects
const person = {firstName:"John", lastName:"Doe", age:50};
"firstName" in person   // Returns true
"age" in person         // Returns true

// Predefined objects
"PI" in Math            // Returns true
"NaN" in Number         // Returns true
"length" in String      // Returns true

instanceof 연산자

instanceof 연산자는 지정된 객체가 지정된 객체의 인스턴스인 경우 true를 반환합니다 .

예시

const cars = ["Saab", "Volvo", "BMW"];

(cars instanceof Array)   // Returns true
(cars instanceof Object)  // Returns true
(cars instanceof String)  // Returns false
(cars instanceof Number)  // Returns false

공허 연산자

void 연산자는 표현식을 평가하고 undefined 반환합니다 . 이 연산자는 "void(0)"을 사용하여 정의되지 않은 기본 값을 얻는 데 자주 사용됩니다(반환 값을 사용하지 않고 표현식을 평가할 때 유용).

예시

<a href="#;">
  Useless link
</a>

<a href="javascript:void(document.body.style.backgroundColor='red');">
  Click me to change the background color of body to red
</a>