If you’re curious about programming in 2021 and still confused with programming languages. Please read this article completely.
Like every other programming language, one has to learn all the basics like data types, variables, loop, conditional statements, array methods, string methods etc.
The loops are as follows:
- for loop
- while loop
- forEach loop
Conditional Statements are used to check conditions. The syntax mostly involves if else statements and switch statements, ternary operators.
Arrays are the special variables which can store more than one value at a time.
Some important Array functions in JS:
- Push: Add element to end
- Pop: Delete element from end
- Delete: Delete an element from index
- Splice: insert in between by deleting some elements
- Concat: concatenate 2 array
- Slice: Getting data from some index to other index
- Sort: Sorting array
- Reverse: Reversing the order of array
Some of the important String methods:
- IndexOf: Gets index of a word in array
- Slice: Gets content from one index to other
- Search: Gives the index of given word
- Substr: Gets the substring from specified index
- Replace: replaces a word
- Split: splits by the given character
Functions & advanced array methods:
One of the most popular JS topics. It is a very powerful method.
It allows us to write short syntax.
####Some of the advanced array methods:
- Filter: Mostly used to remove some data by mapping it in a function
- Map: Maps the array with function
- Reduce: Mostly used with accumulator to perform mathematical operations
OOP (Object Oriented Programming):
JS supports OOPs methodology.
Some terms related are:
- Class: Structure for creating objects
- Constructor: It is a function called by itself when objects are declared.
- Inheritance: When one class inherits the properties from other class. The keyword extends is used there.
- Instance: It is a kind of variable of class. It is declared by using new class_name()
We can access HTML elements using document keyword in JS.
- getElementById: selects element with specified id
- querySelector: selects element with any id, class or tag name
- getElementByClassName: selects elements with specified class name.
There are a lot other DOM methods but only the mostly used ones are specified here
We can add event listener to perform some action when something is done. For example, start timer when button is clicked hence we can can add click event listener to it.
- click: on clicking the element following function runs.
- mousemove: Following action takes place when mouse moves.
There a lot of other event listeners only some are mentioned here.
Some Vanilla JS DOM manipulation projects:
- Simple calculator
- Form validation
- Api fetch
- Spock and rock.
- Typing game
- Speech text reader
- Unit converter
- Navbar animations
- JS game
- Drag and drop
###Modern JS from beginning by Brad Traversy on Udemy
Link to the course
20 Web Vanilla JS projects
There’s a lot more you can do with JS. There are a lot of frameworks for front and back end development. Frameworks like NodeJS, ReactJS, VueJS, AngularJS and a lot more. One can opt to become a MERN/MEAN/MEVN stack web developer. One of the coolest is the guide by Nitin Ranganath MERN Stack Guide on the MERN stack technology.
If you want to build mobile applications, React Native is there to fulfil that demand as well. Alright, now comes desktop applications, you can also build desktop applications using ElectronJS. I agree ML is the future, here you’ve TensorflowJS for ML and AI. Now you see the scope of this programming language. I hope JS is your choice for programming in 2021.