Is it possible to simulate constants in Javascript using closures?

后端 未结 4 397
余生分开走
余生分开走 2021-01-27 09:24

Is it possible to simulate constants in Javascript using closures? If so, can you please furnish me with an example?

4条回答
  •  青春惊慌失措
    2021-01-27 09:50

    This is as far as i got:

    
    
        
            
        
        
            
        
    
    

    This approach allows me to extend the scope to have more than one constant member variable by extending the object literal.

提交回复
热议问题