In Ruby, we are allowed to declare variables containing question mark like this: panelHidden? Is there any way to do this in JS? It gives me an error when I do this.
            Asked
            
        
        
            Active
            
        
            Viewed 30 times
        
    0
            
            
         
    
    
        user117829
        
- 526
- 1
- 8
- 23
- 
                    1This is not possible as it's invalid syntax – Dacre Denny Dec 26 '18 at 20:55
- 
                    @DacreDenny Technically it is possible (ex `window['test?'] = 'weee'`), but you'd be forced to use array notation to access the variable, which is ugly – Taplar Dec 26 '18 at 20:58
- 
                    The question mark character is not a valid JavaScript identifier character. – Pointy Dec 26 '18 at 20:59
- 
                    @Taplar true, but I don't think that's what the author has in mind :) – Dacre Denny Dec 26 '18 at 21:01
- 
                    @Taplar That's a property name, not a variable. (Although in Ruby, `panelHidden?` looks like method name indeed) – Bergi Dec 26 '18 at 22:39