Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how we pass 2 args in switch case javascript

// Declare slider's state "enum"
var SliderOne = {
    A: 1,
    B: 2,
    C: 4,
    D: 8,
    E: 16
};

var SliderTwo = {
    A: 32,
    B: 64,
    C: 128,
    D: 256,
    E: 512
};

// Set state
var s1 = SliderOne.A,
    s2 = SliderTwo.B;

// Switch state
switch (s1 | s2) {
    case SliderOne.A | SliderTwo.A :
    case SliderOne.A | SliderTwo.C :
        // Logic when State #1 is A, and State #2 is either A or C
        break;
    case SliderOne.B | SliderTwo.C :
        // Logic when State #1 is B, and State #2 is C
        break;
    case SliderOne.E | SliderTwo.E :
    default:
        // Logic when State #1 is E, and State #2 is E or
        // none of above match
        break;


}
Comment

PREVIOUS NEXT
Code Example
Javascript :: recharts area chart 
Javascript :: min expression postgresql 
Javascript :: jquery crud table example 
Javascript :: protoypes in constructor functions in javascript 
Javascript :: javascript keyup original src element 
Javascript :: typeorm caching queries time limit globally 
Javascript :: react-native-gesture-handler-react-native-animated-2-tried-to-synchronously-c 
Javascript :: how can click div close and open next day jquery 
Javascript :: ajax javascrit call by value method example 
Javascript :: variable hoisting 
Javascript :: javascript node retry promise.all 
Javascript :: if conprimido js 
Javascript :: Automatically Refresh or Reload a Page using http-equiv 
Javascript :: Adding Notices in the Block Editor Wordpress 
Javascript :: date filter in angular 8 
Javascript :: Subtracting Numbers in Array 
Javascript :: find a node that match a spesific selector string in the paren 
Javascript :: itreating string js 
Javascript :: Learning Arrow function Syntax 
Javascript :: he "slide" event cannot be bound because Hammer.JS is not loaded and no custom loader has been specified 
Javascript :: react show new app 
Javascript :: why in the hell does JavaScript - Date getMonth() return 11 
Javascript :: More generic sort on each condition js 
Javascript :: disable pdf download javascript 
Javascript :: nestjs mongoose ClassSerializerInterceptor not working 
Javascript :: moment js days ago 
Javascript :: hide react from netlify 
Javascript :: Failed: Template parse errors: There is no directive with "exportAs" set to "ngModel" karma 
Javascript :: var quotes 
Javascript :: vue fetch 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =