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 Operators အကိုးအကား


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 Assignment အော်ပရေတာများ

Assignment operator များကို JavaScript variable များသို့ တန်ဖိုးများသတ်မှတ်ရန် အသုံးပြုပါသည်။

x = 10 နှင့် y = 5 တို့ကို ပေး၍ အောက်ပါဇယားတွင် assignment operator များကို ရှင်းပြသည်-

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

assignment operator များအကြောင်း ကျူတိုရီရယ်တစ်ခုအတွက်၊ ကျွန်ုပ်တို့၏ JavaScript Assignment Tutorial ကိုဖတ်ပါ ။



JavaScript String Operator များ

+အော်ပရေတာ နှင့် += အော်ပရေတာ တို့ကိုလည်း (add) strings များ ပေါင်းစပ်ရန် အသုံးပြုနိုင်သည်။

ထို text1 = "Good" , text2 = "Morning" , and text3 = "" ဟူသော ဇယားတွင် အောက်ပါ operator များကို ရှင်းပြသည်-

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 နှိုင်းယှဉ်မှု ကျူတိုရီရယ် ကို ဖတ်ရှုပါ ။


အခြေအနေအလိုက် (Ternary) အော်ပရေတာ

conditional operator သည် အခြေအနေတစ်ခုအပေါ် အခြေခံ၍ variable တစ်ခုသို့ တန်ဖိုးတစ်ခု သတ်မှတ်ပေးသည်။

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

ဥပမာ ရှင်းပြထားသည်- ကိန်းရှင် "အသက်" သည် 18 နှစ်အောက်တန်ဖိုးဖြစ်ပါက၊ ကိန်းရှင် "မဲပေးနိုင်သူ" ၏တန်ဖိုးသည် "ငယ်လွန်းသည်" မဟုတ်ပါက မဲပေးနိုင်သောတန်ဖိုးသည် "အသက်ပြည့်ပြီ" ဖြစ်လိမ့်မည်။


Logical Operators များ

ကိန်းရှင်များ သို့မဟုတ် တန်ဖိုးများအကြား ယုတ္တိဗေဒကို ဆုံးဖြတ်ရန် ယုတ္တိအော်ပရေတာများကို အသုံးပြုသည်။

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 Bitwise အော်ပရေတာများ

ဘစ်အော်ပရေတာများသည် 32 ဘစ်နံပါတ်များပေါ်တွင်အလုပ်လုပ်သည်။ လည်ပတ်မှုတွင် မည်သည့်ဂဏန်း operand ကိုမဆို 32 bit နံပါတ်အဖြစ်သို့ ပြောင်းသည်။ ရလဒ်ကို 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 bits လက်မှတ်မထိုးထားသော ဥပမာများကို အသုံးပြုသည်။ သို့သော် JavaScript သည် 32-bit လက်မှတ်ထိုးထားသော နံပါတ်များကို အသုံးပြုသည်။

ထို့အတွက်ကြောင့် JavaScript တွင် ~ 5 သည် 10 သို့ပြန်မလာပါ။ ၎င်းသည် -6 သို့ပြန်သွားလိမ့်မည်။

~00000000000000000000000000000101 ပြန်လာပါမည် 11111111111111111111111111111010


Operator အမျိုးအစား

အော် ရေတာအမျိုးအစားသည် ပြောင်းလဲနိုင်သော၊ အရာဝတ္ထု၊ လုပ်ဆောင်ချက် သို့မဟုတ် စကားရပ်အမျိုးအစားကို ပြန်ပေးသည်-

ဥပမာ

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 ၏ဒေတာအမျိုးအစားသည် နံပါတ်ဖြစ်သည်။
  • array တစ်ခု၏ data type သည် object ဖြစ်သည်။
  • ရက်စွဲတစ်ခု၏ ဒေတာအမျိုးအစားသည် အရာဝတ္ထုဖြစ်သည်။
  • null ၏ဒေတာအမျိုးအစားသည် အရာဝတ္ထုဖြစ်သည်။
  • သတ်မှတ်မထားသော ကိန်းရှင်တစ်ခု၏ ဒေတာအမျိုးအစားကို သတ်မှတ်မထားပါ။

JavaScript object သည် array (သို့မဟုတ် date) ဖြစ်မဖြစ်ကို သတ်မှတ်ရန် အမျိုးအစားကို အသုံးပြု၍ မရပါ ။


Operator ကို ဖျက်လိုက်ပါ။

ဖျက်ပစ် သည့် အော်ပရေတာသည် အရာဝတ္ထုတစ်ခုမှ ပစ္စည်းတစ်ခုကို ဖျက်သည်-

ဥပမာ

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

ဖျက်ပစ်သည့်အော်ပရေတာသည် ပိုင်ဆိုင်မှုတန်ဖိုးနှင့် ပိုင်ဆိုင်မှုကို ဖျက်သည်။

ဖျက်ပြီးနောက်၊ ၎င်းကို ထပ်မံမထည့်မီ ပိုင်ဆိုင်မှုကို အသုံးမပြုနိုင်ပါ။

ဖျက်ပစ်အော်ပရေတာအား အရာဝတ္တုဂုဏ်သတ္တိများတွင် အသုံးပြုရန် ဒီဇိုင်းထုတ်ထားသည်။ ၎င်းသည် ကိန်းရှင်များ သို့မဟုတ် လုပ်ဆောင်ချက်များအပေါ် သက်ရောက်မှုမရှိပါ။

မှတ်ချက်- ဖျက်ပစ်သည့် အော်ပရေတာအား ကြိုတင်သတ်မှတ်ထားသော JavaScript အရာဝတ္ထုဂုဏ်သတ္တိများတွင် အသုံးမပြုသင့်ပါ။ ၎င်းသည် သင့်လျှောက်လွှာကို ပျက်စီးစေနိုင်သည်။


အော်ပရေတာထဲမှာ

သတ်မှတ်ထားသည့် အ ရာဝတ္တုတွင် သတ်မှတ်ထားသည့်အရာဝတ္တုတွင် ရှိနေပါက၊ သို့မဟုတ် မဟုတ်ပါက မှားယွင်းသည် -

ဥပမာ

// 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

အော်ပရေတာ၏ဥပမာ

သတ်မှတ်ထားသော အရာဝတ္ထုသည် သတ်မှတ်ထားသော အရာဝတ္ထု၏ သာဓကတစ်ခု ဖြစ်ပါက အော်ပရေတာ၏ စံနမူနာသည် မှန် သည် -

ဥပမာ

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(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>