Set.prototype.intersection()
Baseline
2024
Newly available
Since June 2024, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
Set ì¸ì¤í´ì¤ì intersection() ë©ìëë ì§í©ì ë°ìì ì´ ì§í©ê³¼ 주ì´ì§ ì§í©ì ê³µíµ ìì를 í¬í¨íë ì ì§í©ì ë°íí©ëë¤.
구문
intersection(other)
ë§¤ê° ë³ì
other-
Setê°ì²´ í¹ì ì ì¬ ì§í© ê°ì²´
ë°í ê°
ì´ ì§í©ê³¼ other ì§í©ì ê³µíµì¼ë¡ ìë ìì를 í¬í¨íë ì Set ê°ì²´ì
ëë¤.
ì¤ëª
ìíì í기ë²ìì êµì§í©(intersection)ë ë¤ìê³¼ ê°ì´ ì ìë©ëë¤.
벤 ë¤ì´ì´ê·¸ë¨ì¼ë¡ íííìë©´ ìëì ê°ìµëë¤.
intersection()ì other 매ê°ë³ìë¡ ì ì¬ ì§í© ê°ì²´ë¥¼ ë°ìµëë¤. ì¬ì©ì ì½ë를 í¸ì¶íì§ ìê³ thisì ì ì¥ë 기본 ë°ì´í°ë¥¼ ì§ì ê²ìí기 ë문ì ì¤ì Set ì¸ì¤í´ì¤ê° ë기 ìí´ thisê° íìí©ëë¤. ê·¸ë° ë¤ì ëìì thisì otherì í¬ê¸°ì ë°ë¼ ë¬ë¼ì§ëë¤.
thisìother.sizeë³´ë¤ ë§ì ììê° ìì¼ë©´otherìkeys()ë©ìë를 í¸ì¶íì¬otherì ìííê³ ìì±ë 모ë ììë¡thisìë ì¡´ì¬íë ì ì§í©ì 구ì±í©ëë¤.- ê·¸ë ì§ ìì¼ë©´,
thisì ìì를 ìííê³other.has(e)ê°thisìì ì°¸ ê°ì ê°ì ë°ííê² ë§ëë 모ë ììe를 í¬í¨íë ì ì§í©ì ìì±í©ëë¤.
ì´ êµ¬íì¼ë¡ ì¸í´ intersection()ì í¨ì¨ì±ì ì§í©ì ì í ì´í ìê° ë´ì ì¡ì¸ì¤í ì ìë¤ê³ ê°ì í ë ëë¶ë¶ thisì other ì¤ ë ìì ì§í©ì í¬ê¸°ì ë°ë¼ ë¬ë¼ì§ëë¤. ë°íë ì§í©ì ìì ììë thisê³¼ other ì¤ ë ìì ì§í©ì ììì ëì¼í©ëë¤.
ìì
>intersection() ì¬ì©í기
ë¤ì ìë íì ì§í©(<10)ê³¼ ìì ì ê³± ì§í©(<10) ì¬ì´ì êµì§í©ì ê³ì°íë ìì ì ëë¤. ê²°ê³¼ë ìì ì ê³±ì¸ íì ì§í©ì ëë¤.
const odds = new Set([1, 3, 5, 7, 9]);
const squares = new Set([1, 4, 9]);
console.log(odds.intersection(squares)); // Set(2) { 1, 9 }
ëª ì¸ì
| Specification |
|---|
| ECMAScript® 2027 Language Specification> # sec-set.prototype.intersection> |