Advancing with JS

Advancing with JS
0

#1

I’m steadily working through the bonfires and projects and at first I was just happy when I got stuff to work. Now I’m more critical of my knowledge and code.

How can I go from those twenty line functions to the one or two line functions that do the exact same thing? IE tutorials. books, courses etc…

Or does it not even matter, as long as it works it works?


#2

The more you practice solving problems such as these and view other’s code after solving yourself, you will gain knowledge and over time you will see when you can refactor your solution to have less code or even more efficient code.

Just keep practicing, watching tutorials, reading, etc… and you will get there.


#3

As you understand JS and programatic problem solving better, you might enjoy going back to earlier challenges and doing them again. (This is called refactoring.)


#4

Solving the challenges and what not is a feat in itself, learning the clever ways to refactor your code come with experience. There are a number of really great JavaScript books however if you want a deeper understanding of the language.

You Don’t Know JavaScript

Eloquent JavaScript

JavaScript Design Patters


#5

The three links @iamknox posted are really awesome learning material, especially the first one. I love Kyle Simpsons books and videos, he explain’s JavaScript in a very different way and is extremely thoroughly with it. I learned a lot from him.

If you didn’t start already, learning EcmaScript 2015 (ES6) will help you write cleaner code, as this is a newer version of the JavaScript standard with many new language features, such as a different function syntax. I find this a lot cleaner, here is a simple example:

// Old syntax
fs.readFile('file.txt', function(err, content) {
  console.log(content);
});

// New syntax
fs.readFile('file.txt', (err, content) => console.log(content));

There is more of course, just to get you an idea.


#6

Keep in mind that sometimes shorter isn’t always better. There are fancy one-liner solutions out there that can be impressive, however are difficult to decipher. Your code should be readable and understandable to humans.


#7

Hey!

It’s nice to see that you want to improve your JavaScript knowledge!

I suggest you try code challenges on Hackerrank, reading the Mozilla JavaScript web docs and of course, check the FunFunFunction YouTube channel!

He (@mpjme) teaches so nice things about JavaScript, and those things make your code so much better with few lines of code!

I really recommend his channel, it’s helped me a lot!

Happy learning!