Baseline Widely available
String
ê°ì slice()
ë©ìëë ì´ ë¬¸ìì´ì ì¼ë¶ë¥¼ ì¶ì¶íì¬ ì´ë¥¼ ìë¡ì´ 문ìì´ë¡ ë°íí©ëë¤. ì본 문ìì´ì ìì íì§ ììµëë¤.
const str = "The quick brown fox jumps over the lazy dog.";
console.log(str.slice(31));
// Expected output: "the lazy dog."
console.log(str.slice(4, 19));
// Expected output: "quick brown fox"
console.log(str.slice(-4));
// Expected output: "dog."
console.log(str.slice(-9, -5));
// Expected output: "lazy"
문ë²
slice(indexStart)
slice(indexStart, indexEnd)
매ê°ë³ì
indexStart
ë°íë ë¶ë¶ 문ìì´ì í¬í¨ë 첫 ë²ì§¸ 문ìì ì¸ë±ì¤.
indexEnd
Optional
ë°íë ë¶ë¶ 문ìì´ìì ì ì¸ë 첫 ë²ì§¸ 문ìì´ì ì¸ë±ì¤.
문ìì´ì ì¶ì¶ë ë¶ë¶ì ë´ë ìë¡ì´ 문ìì´ì´ ë°íë©ëë¤.
ì¤ëªslice()
ë íëì 문ìì´ë¡ë¶í° í
ì¤í¸ë¥¼ ì¶ì¶íê³ ì 문ìì´ì ë°íí©ëë¤.
slice()
ë indexEnd
를 í¬í¨íì§ ìê³ ì¶ì¶í©ëë¤. ì를 ë¤ì´ str.slice(4, 8)
ë ë¤ì¯ ë²ì§¸ 문ìë¶í° ì¬ë ë²ì§¸ 문ìê¹ì§ ì¶ì¶í©ëë¤(ì¸ë±ì¤ 4
, 5
, 6
, 7
ì í´ë¹íë 문ì).
indexStart indexEnd â â | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | | T | h | e | | m | i | r | r | o | r | m i r r _______________ â Result
indexStart >= str.length
ì´ë¼ë©´, ë¹ ë¬¸ìì´ì´ ë°íë©ëë¤.indexStart < 0
ì´ë¼ë©´, 문ìì´ì ëë¶í° ì¸ë±ì¤ë¥¼ ì
ëë¤. ë³´ë¤ ê³µìì ì¼ë¡ ë§íìë©´ ì´ ê²½ì°, íì 문ìì´ì max(indexStart + str.length, 0)
ìì ììí©ëë¤.indexStart
ê° ìëµëìê±°ë ì ìëì§ ììê±°ë ì«ìë¡ ë³íí ì ìë ê²½ì°, 0
ì¼ë¡ ì²ë¦¬ë©ëë¤.indexEnd
ê° ìëµëìê±°ë í¹ì ì ìëì§ ììê±°ë í¹ì indexEnd >= str.length
ì´ë©´ slice()
ë 문ìì´ ëì¼ë¡ ì¶ì¶í©ëë¤.indexEnd < 0
ì´ë©´ 문ìì´ì ëë¶í° ì¸ë±ì¤ë¥¼ ì
ëë¤. ë³´ë¤ ê³µìì ì¼ë¡ ë§íìë©´ ì´ ê²½ì°, íì 문ìì´ì max(indexEnd + str.length, 0)
ìì ëë©ëë¤.indexEnd
ê° indexStart
ìì ìë 문ì를 ëíë´ë ê²½ì°) indexEnd <= indexStart
ì¸ ê²½ì° ë¹ ë¬¸ìì´ì´ ë°íë©ëë¤.slice()
를 ì¬ì©íì¬ ì 문ìì´ ìì±í기
ìë ìì ë ì 문ìì´ì ìì±í기 ìí´ slice()
를 ì¬ì©í©ëë¤.
const str1 = "The morning is upon us."; // str1ì 길ì´ë 23ì
ëë¤.
const str2 = str1.slice(1, 8);
const str3 = str1.slice(4, -2);
const str4 = str1.slice(12);
const str5 = str1.slice(30);
console.log(str2); // he morn
console.log(str3); // morning is upon u
console.log(str4); // is upon us.
console.log(str5); // ""
ìì ì¸ë±ì¤ë¡ slice()
ì¬ì©í기
ìë ììë slice()
ì ìì ì¸ë±ì¤ë¥¼ ì¬ì©í©ëë¤.
const str = "The morning is upon us.";
str.slice(-3); // 'us.'
str.slice(-3, -1); // 'us'
str.slice(0, -1); // 'The morning is upon us'
str.slice(4, -1); // 'morning is upon us'
ìëì ììë ìì ì¸ë±ì¤ë¥¼ 찾기 ìí´ ë¬¸ìì´ì ëììë¶í° ìë°©í¥ì¼ë¡ 11
ê°ë¥¼ ì¸ê³ ë ì¸ë±ì¤ë¥¼ 찾기 ìí´ ë¬¸ìì´ì ììììë¶í° ì ë°©í¥ì¼ë¡ 16
ê°ë¥¼ ì
ëë¤.
console.log(str.slice(-11, 16)); // "is u"
ìëììë ìì ì¸ë±ì¤ë¥¼ 찾기 ìí´ ë¬¸ìì´ì ì²ìë¶í° ì ë°©í¥ì¼ë¡ 11
ê°ë¥¼ ì¸ê³ ë ì¸ë±ì¤ë¥¼ 찾기 ìí´ ëììë¶í° 7
ê°ë¥¼ ì
ëë¤.
console.log(str.slice(11, -7)); // " is u"
ì´ ì¸ìë ëììë¶í° 5ë¡ ììì¼ë¡ ê³ì°íì¬ ìì ì¸ë±ì¤ë¥¼ ì°¾ì ë¤ì ëììë¶í° 1ì ê±°ì³ ë ì¸ë±ì¤ë¥¼ ì°¾ìµëë¤.
console.log(str.slice(-5, -1)); // "n us"
ëª
ì¸ì ë¸ë¼ì°ì í¸íì± ê°ì´ 보기
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