<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[JS קבלת מערך של סוגי התנאים הקיימים למשתנה מסויים]]></title><description><![CDATA[<p dir="rtl">נניח יש לי קוד כזה</p>
<pre><code>let Action = query['Action'];
if (Action === 'new'){
    //bla bla
}else if (Action === 'user'){
    //bla bla
}else if (Action === 'play'){
    //bla bla
}else if (Action === 'move'){
    //bla bla
}
let AllActions = ???
</code></pre>
<p dir="rtl">הבעיה היא שהקוד ארוך ארוך ואני מוסיף תנאים מרובים.<br />
ברצוני לקבל באיזה שהוא דרך מערך של כל התנאים הקיימים בקוד עבור משתנה Action בכדי שאוכל ליצור לעצמי API פנימי שאוכל ליצור לעצמי בסביבת הבדיקה שאוכל בקלות לקבל רשימת האפשרויות ואז אוכל לבחור ולגשת בקלות לפונקציה המבוקשת.<br />
יש למישהו רעיון איך ניתן ליישם כזה דבר?</p>
]]></description><link>https://tchumim.com/topic/9496/js-קבלת-מערך-של-סוגי-התנאים-הקיימים-למשתנה-מסויים</link><generator>RSS for Node</generator><lastBuildDate>Fri, 06 Nov 2026 14:13:52 GMT</lastBuildDate><atom:link href="https://tchumim.com/topic/9496.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 25 Jul 2020 20:53:40 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to JS קבלת מערך של סוגי התנאים הקיימים למשתנה מסויים on Sat, 25 Jul 2020 21:26:59 GMT]]></title><description><![CDATA[<p dir="rtl">סתם יותר נקי</p>
<pre><code>const actionsHandler = {
    new,
    user
};
function new(){

}

 

function user(){

}
</code></pre>
]]></description><link>https://tchumim.com/post/107594</link><guid isPermaLink="true">https://tchumim.com/post/107594</guid><dc:creator><![CDATA[יוסף בן שמעון]]></dc:creator><pubDate>Sat, 25 Jul 2020 21:26:59 GMT</pubDate></item><item><title><![CDATA[Reply to JS קבלת מערך של סוגי התנאים הקיימים למשתנה מסויים on Sat, 25 Jul 2020 21:15:59 GMT]]></title><description><![CDATA[<p dir="rtl"><a class="plugin-mentions-user plugin-mentions-a" href="/user/%D7%97%D7%95%D7%A7%D7%A8" aria-label="Profile: חוקר">@<bdi>חוקר</bdi></a> אתה יכול להשאיר את הקוד בפונקציות ורק למיפוי לעשות אובייקט שערך מביא פוקנציה (ציון שמה):</p>
<pre><code>const actionsHandler = {
    "new": new,
    "user": user
};

function new(){
}

function user(){
}
 
</code></pre>
<p dir="rtl">אבל זה סתם עניין של איך לסדר את הקוד</p>
]]></description><link>https://tchumim.com/post/107592</link><guid isPermaLink="true">https://tchumim.com/post/107592</guid><dc:creator><![CDATA[dovid]]></dc:creator><pubDate>Sat, 25 Jul 2020 21:15:59 GMT</pubDate></item><item><title><![CDATA[Reply to JS קבלת מערך של סוגי התנאים הקיימים למשתנה מסויים on Sat, 25 Jul 2020 21:08:55 GMT]]></title><description><![CDATA[<p dir="rtl">זה אומר בעצם להעביר את כל הפעילות מתוך הקוד לתוך אובייקט?</p>
]]></description><link>https://tchumim.com/post/107590</link><guid isPermaLink="true">https://tchumim.com/post/107590</guid><dc:creator><![CDATA[חוקר]]></dc:creator><pubDate>Sat, 25 Jul 2020 21:08:55 GMT</pubDate></item><item><title><![CDATA[Reply to JS קבלת מערך של סוגי התנאים הקיימים למשתנה מסויים on Sat, 25 Jul 2020 21:13:26 GMT]]></title><description><![CDATA[<p dir="rtl"><a class="plugin-mentions-user plugin-mentions-a" href="/user/%D7%97%D7%95%D7%A7%D7%A8" aria-label="Profile: חוקר">@<bdi>חוקר</bdi></a> אמר ב<a href="/post/107585">JS קבלת מערך של סוגי התנאים הקיימים למשתנה מסויים</a>:</p>
<blockquote>
<p dir="auto">let Action = query['Action'];</p>
</blockquote>
<pre><code>const actionsHandler = {
    new(){
        //bla bla
    },
    user(){
        //bla bla
    }
}

let Action = query['Action'];
actionsHandler[Action]();
let AllActions = Object.keys(actionsHandler)
</code></pre>
]]></description><link>https://tchumim.com/post/107588</link><guid isPermaLink="true">https://tchumim.com/post/107588</guid><dc:creator><![CDATA[יוסף בן שמעון]]></dc:creator><pubDate>Sat, 25 Jul 2020 21:13:26 GMT</pubDate></item></channel></rss>