JavaScript & jquery by Jon Ducket out of date?

JavaScript & jquery by Jon Ducket out of date?
0

#1

Ok so I am brand new to JavaScript, I got Jon Duckets book and I’m going through one of the first examples which I could not get to work, here is my code and how I fixed it.

Constructive & Co.
<h1>Constructive &amp; Co.</h1>
<script src="js/add-content.js"></script>
<p>For all orders and inquiries please call <em>555-3344</em></p>

var today = new Date ();
var hourNow = today.getHours();
var greeting;

if (hourNow > 18) {
greeting = ‘Good evening!’;
} else if (hourNow > 12) {
greeting = ‘Good afternoon!’;
} else if (hourNow > 0); {
greeting = ‘Good morning!’;
} else {
greeting = ‘Weclcome!’;
}

document.write(’

’ + greeting + ‘

’);

I ran that through codepen and got an error index.js: Unexpected token (11:2) so I removed the “else” on line 11 and it now seems to work.

So my question is, is this out of date? Or am I missing something? I’ve just started learning JavaScript so I don’t really have a lot of knowledge to pull from.


#2

You have a semicolon here that should not be there.

else if (hourNow > 0);


#3

One of your issues will likely be this:

<script src="js/add-content.js"></script>

it will look for a folder called js with a file named add-content.js from wherever you run this script from.


#4

To answer the question on two levels:

  • The book was printed in 2013, so yes technically it could be considered out of date. The book covers the ES5 version of JavaScript, which is still widely in use, but ES6 is also widely in use today now too. And although many websites stll use jQuery, it’s considered an “old” technology now.
  • That said, the code in the book should still work (any errata aside) and you shouldn’t have any issues with it. You’ll just be using older version of some things, like jQuery.

#5

Just to give another opinion… there’s still plenty of sites that use ES5 and jQuery. Not to mention there’s lots of senior developers who prefer to read ES5 & refuse to learn ES6. The one you’ll use will likely be dictated by whomever you work for.

I refuse to use ES6 until IE decides to finally use it. It’s still important to learn though.


#6

So do you think it would be best to learn ES5 first and then learn ES6 or vice versa?

What has replaced jQuery?


#7

This means you’ll never use most ES6 features; the last remaining version of IE still supported by only MS receives security updates until Windows 10 support ends in 2025. It seems a strange reason to avoid using ES6 unless all of the users of your code are locked into IE, otherwise the market share Vs Chrome/FF/Edge is tiny (and Edge is being rebuilt on top of Chromium and will be backward-compatible to Win7/8, so there should be very few IE users left by that point that drops)


#8

@DanCouper

I’m a web developer and by default IE comes with every windows machine. Not every person is savy enough to download chrome. Yeah., I know, sounds crazy but true. So unless you want to miss out on that entire market., I wouldn’t go full ES6. ( Now this is just my opinion ). So take it for what it’s worth. Everything comes down to what your company wants to use.

From what I understand., the next version of IE is supposed to support ES6.


#9

In my opinion, I would learn es5 first since there is far more code written in it. As for your jQuery question, there’s plenty of libraries out there. I’m trying to avoid using it all together and just use vanilla JS instead.

If you need to use some sort of datepicker control then you may end up using the jquery min file. If you do go that route., try to use the CDN.


#10

There isn’t a next version of IE though, the last version was released in 2013 and it receives nothing but security patches, there will never be another version of it. This is what I mean, you’re saying you won’t ever learn newer JS features. The default browser on Windows 10 (which makes up the majority of installs) is not IE and supports all ES6 features just fine (and as it’s the same engine as Chrome going forwards, it’ll have even closer [than the already very close] feature parity)