Using an object anonymously in JavaScript

1380 views
var month = 'Jan'; //or another three-letter abbreviation

//After the following operation, proper_month will contain the string "January".
var proper_month = {'Jan':'January',
                              'Feb': 'February',
                              'Mar' : 'March',
                              'Apr' : 'April',
                              'May'   : 'May',
                              'Jun'  : 'June',
                              'Jul'  : 'July',
                              'Aug'   : 'August',
                              'Sep'  : 'September',
                              'Oct'   : 'October',
                              'Nov'   : 'November',
                              'Dec'   : 'December'
                             
                             }[month];
Learn Quranic Arabic with my book!
Available in both paperback and Kindle formats.
Comments

Leave a Reply

Commenting rules: 1. We respect your right to disagree with anything we say. But comments with profanity and insults will be deleted.
2. Only English-language comments are allowed.

Your email address will not be published. Required fields are marked *