Earlier quoted context omitted.
The actual quote was: >>What I’m saying is don’t rely heavily on jQuery, or any other library, without having some sort of understanding of how that library is accomplishing it’s tasks. Which I think is fair. (However, I don't agree with his assertion that using vanilla JS will be more efficient - in most cases, it won't.)
Vanilla JS is more efficient than jQuery a lot of the time - for example, consider the $(...) api - this has to do string parsing before it makes its selector call, which by its very nature take away computing power. These days it is negligible though. The argument for using jQuery for DOM manipulation is oftentimes just one of readability.
Tips to Become a Better JavaScript Developer
41–46 of 46 posts
Re: Tips to Become a Better JavaScript Developer
#42Earlier quoted context omitted.
Vanilla JS is more efficient than jQuery a lot of the time - for example, consider the $(...) api - this has to do string parsing before it makes its selector call, which by its very nature take away computing power. These days it is negligible though. The argument for using jQuery for DOM manipulation is oftentimes just one of readability.
In 99% cases the performance difference doesn't matter - users won't notice that a jQuery method runs 5ms slower than it would run in vanilla JS, but they will notice if the script doesn't work at all, because your vanilla JS code fails on older browsers.
Re: Tips to Become a Better JavaScript Developer
#43only needs one point, "only use javascript when you have to, it's a terrible language and best avoided"
Why do you think its terrible?
the scoping sucks, e.g.
(function() {
var x = 1;
console.log( x );
if ( x ) {
var y = 2;
}
console.log( y );
})()
why is y defined? its being called out of the block it was declared in?there's no proper foreach using other files is an effort and requires hacks to get them loaded. callbacks everywhere. variable names as object keys is a pain regex is a pita
i just don't like it, i have no idea why it's become so popular recently, i can understand it runs in the browser and everyone has a browser, but why server side stuff?
but whatever, each to their own i guess
Re: Tips to Become a Better JavaScript Developer
#44Re: Tips to Become a Better JavaScript Developer
#45Earlier quoted context omitted.
Why do you think its terrible?
the + operator, is it concatting strings, or adding? who knows. the scoping sucks, e.g. (function() { var x = 1; console.log( x ); if ( x ) { var y = 2; } console.log( y ); })() why is y defined? its being called out of the block it was declared in? there's no proper foreach using other files is an effort and requires hacks to get them loaded. callbacks everywhere. variable names as object keys is a pain regex is a p…
Javascript doesn't have block scope; above example is equivalent to:
(function() {
var x, y;
x = 1;
console.log( x );
if ( x ) {
y = 2;
}
console.log( y );
})()
Variable declarations are always hoisted to the top of containing scope.Re: Tips to Become a Better JavaScript Developer
#46I apologize for the inaccuracies. I was just looking to help some beginner JavaScript developers.