JavaScript String အကိုးအကား
JavaScript ကြိုးများ
JavaScript string တစ်ခုသည် "John Doe" ကဲ့သို့သော ဇာတ်ကောင်အတွဲလိုက်ကို သိမ်းဆည်းထားသည်။
စာကြောင်းတစ်ကြောင်းသည် ကိုးကားနှစ်ထပ် သို့မဟုတ် တစ်ခုတည်းရှိ စာသားတစ်ခုခု ဖြစ်နိုင်သည်-
let carName1 = "Volvo XC60";
let carName2 = 'Volvo XC60';
စာကြောင်းအညွှန်းများသည် သုညအခြေခံဖြစ်သည်-
ပထမဇာတ်ကောင်သည် 0 တွင်ရှိပြီး ဒုတိယ 1 တွင် စသည်တို့ဖြစ်သည်။
Strings အကြောင်း သင်ခန်းစာအတွက်၊ ကျွန်ုပ်တို့၏ JavaScript String Tutorial ကို ဖတ်ရှုပါ ။
String Properties နှင့် Methods
ပုံမှန်အားဖြင့်၊ "John Doe" ကဲ့သို့သော စာကြောင်းများသည် အရာဝတ္တုများမဟုတ်သောကြောင့် နည်းလမ်းများ သို့မဟုတ် ဂုဏ်သတ္တိများ မရှိနိုင်ပါ။
သို့သော် JavaScript ဖြင့်၊ နည်းလမ်းများနှင့် ဂုဏ်သတ္တိများကို strings များတွင် ရရှိနိုင်သည်၊ အကြောင်းမှာ JavaScript သည် နည်းလမ်းများနှင့် ဂုဏ်သတ္တိများကို လုပ်ဆောင်သောအခါတွင် string များကို အရာဝတ္ထုများအဖြစ် သတ်မှတ်ပေးသောကြောင့် ဖြစ်သည်။
JavaScript String Methods
Method | Description |
---|---|
charAt() | Returns the character at a specified index (position) |
charCodeAt() | Returns the Unicode of the character at a specified index |
concat() | Returns two or more joined strings |
endsWith() | Returns if a string ends with a specified value |
fromCharCode() | Returns Unicode values as characters |
includes() | Returns if a string contains a specified value |
indexOf() | Returns the index (position) of the first occurrence of a value in a string |
lastIndexOf() | Returns the index (position) of the last occurrence of a value in a string |
localeCompare() | Compares two strings in the current locale |
match() | Searches a string for a value, or a regular expression, and returns the matches |
repeat() | Returns a new string with a number of copies of a string |
replace() | Searches a string for a value, or a regular expression, and returns a string where the values are replaced |
search() | Searches a string for a value, or regular expression, and returns the index (position) of the match |
slice() | Extracts a part of a string and returns a new string |
split() | Splits a string into an array of substrings |
startsWith() | Checks whether a string begins with specified characters |
substr() | Extracts a number of characters from a string, from a start index (position) |
substring() | Extracts characters from a string, between two specified indices (positions) |
toLocaleLowerCase() | Returns a string converted to lowercase letters, using the host's locale |
toLocaleUpperCase() | Returns a string converted to uppercase letters, using the host's locale |
toLowerCase() | Returns a string converted to lowercase letters |
toString() | Returns a string or a string object as a string |
toUpperCase() | Returns a string converted to uppercase letters |
trim() | Returns a string with removed whitespaces |
valueOf() | Returns the primitive value of a string or a string object |
မှတ်ချက်
စာကြောင်းနည်းလမ်းအားလုံးသည် တန်ဖိုးအသစ်တစ်ခု ပြန်ပေးသည်။
၎င်းတို့သည် မူရင်းကိန်းရှင်ကို မပြောင်းလဲပါ။
JavaScript String Properties
Property | Description |
---|---|
constructor | Returns the string's constructor function |
length | Returns the length of a string |
prototype | Allows you to add properties and methods to an object |
string HTML Wrapper နည်းလမ်းများ
HTML wrapper နည်းလမ်းများသည် HTML tag တစ်ခုအတွင်း ပတ်ထားသော စာကြောင်းကို ပြန်ပေးသည်။
၎င်းတို့သည် စံနည်းလမ်းများမဟုတ်သောကြောင့် မျှော်လင့်ထားသည့်အတိုင်း အလုပ်မဖြစ်နိုင်ပါ။
Method | Description |
---|---|
anchor() | Displays a string as an anchor |
big() | Displays a string using a big font |
blink() | Displays a blinking string |
bold() | Displays a string in bold |
fixed() | Displays a string using a fixed-pitch font |
fontcolor() | Displays a string using a specified color |
fontsize() | Displays a string using a specified size |
italics() | Displays a string in italic |
link() | Displays a string as a hyperlink |
small() | Displays a string using a small font |
strike() | Displays a string with a strikethrough |
sub() | Displays a string as subscript text |
sup() | Displays a string as superscript text |