TIL to put JavaScript object keys in quotes

Today I learned to put JavaScript object keys in quotes ALL OF THE TIME. Technically you don’t have to but if you’re using jQuery as a framework keys that contain a hyphen and keys that are already keywords in JavaScript require quotes. So just surround all your keys with quotes and there won’t be a problem. Example: 'height' : '60px' where height is the key (and 60px is the value).

Leave a Reply

Wordpress theme JaeDubya © 2018 | All Right Reserved | Designed & coded by J. Arthur Wetenkamp