With every programming language, there’s a list of best practices; do’s and don’ts. JavaScript is no exception. Some of these best practices are there for your protection (like always always always using semi-colons!), some to make your code more readable and less error-prone, and some to increase the efficiency of your code.
Don’t miss an upload! Subscribe! http://goo.gl/szEauh
Stay Connected to O’Reilly Media by Email – http://goo.gl/YZSWbO
Follow O’Reilly Media:
http://plus.google.com/+oreillymedia
https://www.facebook.com/OReilly
Tweets by OReillyMedia
Original source
19 responses to “Dos and Donts: Best Practices When Learning JavaScript”
I went through everything on JavaScript at 3wschools, I can use all of them individually but still can't build any meaningful app. I can change contents on DOM, change styles, change image SRC but that is where it ends. where can I learn advance stuffs, like building a real life app
thank you!
Thank you for these tips!
Shouldn't message be set to div.innerHTML instead of empty string? What if we supposed to process more than one array?
Should I learn Javascript or Python ?
Some of these are applicable not only to JS, but to any programming language.
Very good stuff women.
write code for humans not computers. Don't Repeat Yourself. Keep it Simple.
great video o'reilly , its better then other videos i saw 🙂
This is excellent marketing, might I say!
I tried this and does not work inside my body:
<script>
function arrayFromObject (obj) {
var theArray = [];
var i = 0;
for (var key in obj) {
theArray[i] = 0;
i++;
}
return theArray;
}
</script>
She forgot 1 at the example at 10:26:
it's faster to declare a variable storing the length of an array (exept when you add elements to the array and need the new length) like this:
for (var i = 0, len = myArray.length; i < len; i++) {
Difficult to follow.
Most of these aren't exclusive to Javascript, and this video could definitely have been reduced to a 5 second list. Also, the intro was kinda' creepy (not much offense intended).
I think that there is an error in that first example of choosing good variable names.
This will cast all values of the object as 0
Should the line theArray[i] = 0 not be
theArray[i] = obj[key];
The narrator is sooo professional and then, at 8:23, with a barely detectable break in her demeanor: "… something called Automatic Semi-Colon Insertion. It sounds complicated and perhaps a little painful…" I love that she did that 🙂 Very funny
Some really nice tips. Thanks for the teaser.
Useful intro and appreciate the clear voice, but drop the silly stock pictures. "You can't have two variable names with the same names." might want to word that better.
Thanks