Seven JavaScript Things I Wish I Knew Much Earlier In My Career
I’ve been writing JavaScript code for much longer than I care to remember. I am very excited about the language’s recent success; it’s good to be a part of that success story. I’ve written dozens of articles, book chapters and one full book on the matter, and yet I keep finding new things. Here are some of the “aha!” moments I’ve had in the past, which you can try out rather than waiting for them to come to you by chance. [Offtopic: by the way, did you know that there is a Smashing eBook Series? Book #1 is Professional Web Design, 242 pages for just $9,90.] Shortcut Notations One of the things I love most about JavaScript now is shortcut notations to generate objects and arrays. So, in the past when we wanted to create an object, we wrote: var car = new Object(); car.colour = 'red'; car.wheels = 4; car.hubcaps = 'spinning'; car.age = 4; The same can be achieved with: var car = { colour:'red', wheels:4, hubcaps:'spinning', age:4 } Much shorter, and you don’t need to repeat the name of the object. Right now, car is fine, but what happens when you use invalidUserInS
Published at 3 months ago