DEV Community

loading...

Where do I start? Part 3: JavaScript

kevindsteeleii profile image Kevin Steele ・3 min read

This time

Hi all, I'm back with another installment of these lists of lists. This time around I'm talking about JavaScript. So as always, I'm just some guy and by no means an expert please correct me in the comments if I'm talking out of the side of my you-know-what.

JavaScript

JavaScript is an amazing language. You can manipulate the DOM, build games, and make cool apps. There are many things you can do in this language but I'll highlight some of the things beginners need to learn and most of this will apply to other languages as well.

I said in a previous post to learn JavaScript after all the other things like HTML and CSS. But, if you really want to learn JavaScript, do so in isolation and that's how I would tell you to practice, at first. But if you're already familiar with HTML and CSS, go for it! I believe in you!

Things to learn

There's a lot to learn in any language and it can be confusing for your first so here are some personal favorite resources on learning JavaScript.

Topics to Study:

  • variables, how to define them
    • let & const (don't use var, I mean it!!)
    • variable scope (is the variable accessible)
  • data types
    • number, string, boolean, symbol
    • type conversion and testing, typeof
  • reference data types
    • objects, arrays, etc.
  • operators
    • addition, subtraction, division, multiplication, and more!! (+, -, /, *)
  • functions
    • a reusable piece of code that is sometimes called a procedure if it doesn't return anything, but everyone just says function, unless they're being fancy or pedantic
    • control flow
      • loops
        • for, while, for-in, for-of
      • conditional statements
        • if, else if, else, [try, catch, finally] -> debugging
  • keyword this
    • call, apply, and bind -> when/how to use them and where
  • arrow functions

  • DOM Manipulation

    • create, remove, modifying an element
    • adding CSS class to element to modify it

Resources

Next time I'll share some links on learning OOP or object-oriented programming in JS and how their classes work. There is a wealth of resources online and I can't hope to cover them all but I think these are pretty good and as always I'm open to any comments, critiques, or call outs.

Discussion (7)

pic
Editor guide
Collapse
bigmabe profile image
E.Mabry

Kevin,
Great post, but why do you feel using "var" is a non-starter? Since, I use it quite often. Is this a bad coding practice?

Collapse
arximughal profile image
Muhammad Arslan Aslam

According to some JavaScript experts, yes. You shouldn't use var. Use const &/|| let.

The reason for that,

  • var isn't block-scoped
  • No warnings/errors given if you declare the same variable twice using var
  • Some modern linters give warnings stating var is a bad coding practice

More in-depth article here:

Collapse
zac_heisey profile image
Zac Heisey • Edited

I think Muhammad brings up some solid points here as to why you wouldn't want to use var. However, I don't agree with the author's notion that var should never be used. In fact, I'd argue that using var in the early stages of learning JavaScript will make the concept of declaring, changing, and working with variables easier to understand.

Chris Ferdinandi, a vanilla JavaScipt expert, has a nice explanation on why he doesn't use let or const in his projects: gomakethings.com/why-i-dont-use-le...

His reasoning: let and const aren't as backwards compatible as var, they can't be polyfilled, and trying to determing which type to use adds unnecessary cognitive overhead (especially for beginners).

Thread Thread
arximughal profile image
Muhammad Arslan Aslam

I totally agree with you. For a beginner, using var can be a good thing to understand working with variables.

Collapse
bigmabe profile image
E.Mabry

Thanks for that explanation. I never looked at it that way Muhammad. After reading the article I understand. I just have never had any problem with it. I do see the benefit with block-scoped and I do recognize the errors it gives using some linters. I will give it a try.

Thread Thread
arximughal profile image
Muhammad Arslan Aslam

Glad I could help <3

Collapse
horus_sky profile image
Cedric W • Edited

Forcing myself to really learn JS so this article is great. I've worked in JS/jQuery for years but never fully understood them other than from working experience and by proxy. Mostly using the SoloLearn app on my phone to learn and finding opportunities at work to put it into practice.