Baseline Widely available
String
ê°ì at()
ë©ìëë ì ì ê°ì ë°ì ì§ì ë ì¤íì
ì ìì¹í ë¨ì¼ UTF-16 ì½ë ì ëì¼ë¡ 구ì±ë ìë¡ì´ String
ì ë°íí©ëë¤. ì´ ë©ìëë ìì ì ìì ìì ì ì를 모ë íì©í©ëë¤. ìì ì ìë 문ìì´ì ë§ì§ë§ 문ìë¶í° ê±°ê¾¸ë¡ ì¸ì´ ìì¹ë¥¼ ì§ì í©ëë¤.
const sentence = "The quick brown fox jumps over the lazy dog.";
let index = 5;
console.log(`An index of ${index} returns the character ${sentence.at(index)}`);
// Expected output: "An index of 5 returns the character u"
index = -4;
console.log(`An index of ${index} returns the character ${sentence.at(index)}`);
// Expected output: "An index of -4 returns the character d"
구문 매ê°ë³ì
index
ë°íí 문ìì´ ë¬¸ìì ì¸ë±ì¤(ìì¹)ì ëë¤. ìì ì¸ë±ì¤ë¥¼ ì ë¬íë©´ 문ìì´ ëììë¶í°ì ìëì ì¸ë±ì±ì ì§ìí©ëë¤. ì¦, ììê° ì¬ì©ëë©´ ë°íëë 문ìë 문ìì´ì ëììë¶í° ê±°ê¾¸ë¡ ì¸ì´ ì°¾ìì§ëë¤.
ì§ì ë ìì¹ì ìë ë¨ì¼ UTF-16 ì½ë ì ëì¼ë¡ 구ì±ë String
ì ë°íí©ëë¤. 주ì´ì§ ì¸ë±ì¤ë¥¼ ì°¾ì ì ìì¼ë©´ undefined
를 ë°íí©ëë¤.
ë¤ì ìì ë 주ì´ì§ 문ìì´ìì ë§ì§ë§ 문ì를 ë°ííë í¨ì를 ì ê³µí©ëë¤.
// 주ì´ì§ 문ìì´ìì ë§ì§ë§ 문ì를 ë°ííë í¨ì
function returnLast(arr) {
return arr.at(-1);
}
let invoiceRef = "myinvoice01";
console.log(returnLast(invoiceRef)); // '1'
invoiceRef = "myinvoice02";
console.log(returnLast(invoiceRef)); // '2'
ë©ìë ë¹êµí기
ì¬ê¸°ìë String
ì ëìì ë ë²ì§¸(ë§ì§ë§ìì íë ì) 문ì를 ì ííë ë¤ìí ë°©ë²ì ë¹êµí©ëë¤. ìëì 모ë ë°©ë²ì´ ì í¨íì§ë§, ì´ë at()
ë©ìëì ê°ê²°ì±ê³¼ ê°ë
ì±ì ê°ì¡°í©ëë¤.
const myString = "Every green bus drives fast.";
// length ìì±ê³¼ charAt() ë©ìë ì¬ì©í기
const lengthWay = myString.charAt(myString.length - 2);
console.log(lengthWay); // 't'
// slice() ë©ìë ì¬ì©í기
const sliceWay = myString.slice(-2, -1);
console.log(sliceWay); // 't'
// at() ë©ìë ì¬ì©í기
const atWay = myString.at(-2);
console.log(atWay); // 't'
ëª
ì¸ì ë¸ë¼ì°ì í¸íì± ê°ì´ 보기
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4