Getting Started With JavaScript

Getting Started With JavaScript

·

4 min read

What is JavaScript?

JavaScript is a high-level programming language that conforms to the Scripting specification. It is a text-based programming language used both on the client-side and the server-side that allows you to make web pages responsive. This is to say that while HTML and CSS give structure, design, and style to a website JavaScript gives web pages interactive elements that engage the user which makes your webpage more user-friendly.

Keywords in JavaScript

Variables: usually declared as Var in JS are containers that hold re-usable data or data values. These variables must be created before any code can be executed in JavaScript. Variables can hold values that have different data types :

  • String: This is a sequence of text it is usually enclosed in a single quote.

  • Number: This is a number. Numbers don't have quotes around them.

  • Boolean: These are true or false values. Which do not need any quotation mark.

  • Array: These are structures that allow you to store multiple values in a single reference.

  • Object: Everything in JavaScript is an object and can be stored in a variable.

COMMENTS: Comments are texts that can be added along with code. The browser ignores text marked as comments. We have two types of comments in JavaScript,

  • The single-line comment which usually starts with two forward slashes [//]
// Change heading:
document.getElementById("myH").innerHTML = "My First Page";

// Change paragraph:
document.getElementById("myP").innerHTML = "My first paragraph.";
  • The multiline comment which begins with an asterisk and a slash[*/]
/*
The code below will change
the heading with id = "myH"
and the paragraph with id = "myP"
in my web page:
*/
document.getElementById("myH").innerHTML = "My First Page";
document.getElementById("myP").innerHTML = "My first paragraph.";

Operators: An operator is a mathematical symbol that produces a result based on two values (or variables).

Functions: Functions are groups of reusable code that can be called anywhere in your program. This eliminates the need of writing the same code again and again. A JavaScript function is executed when "something" invokes it.

function myFunction(p1, p2) {
  return p1 * p2;   // The function returns the product of p1 and p2
}

Events: Events occur when some sort of interaction takes place on a web page. This can be the end-user clicking on something, moving the mouse over a certain element, or pressing down certain keys on the keyboard. An event can also be something that happens in the web browser, such as the web page completing the loading of a page, or the user scrolling or resizing the window.

Why Choose JavaScript?

  • JavaScript is the most popular programming language: According to Stackoverflow.com, JavaScript is the most popular programming language used by professional developers today. Even back-end developers choose JavaScript more often than not.

  • JavaScript is versatile: Far from being a one-trick pony, JavaScript empowers a programmer to handle any aspect of app design. Do you want to do client-side (front-end) coding? You can use a javascript framework like Angular. Are you more interested in the server-side (back-end)? Node.js is there to do the trick You can also create desktop, mobile, and web apps with JS

  • JavaScript is quite easy to learn: JavaScript which is a lightweight, interpreted language is a natural language to use and is also easy to pick up since it can easily be embedded with HTML and CSS.

  • JavaScript allows for creativity: It's one thing to build a webpage, it's also another to build an eye-catching webpage. JavaScript allows users to create visually appealing webpages that attract the user’s attention and encourages interaction. With JavaScript, you can use easily add cool design elements such as animation and interactive maps.

  • JavaScript Career opportunities are unending: With an increasing number of businesses and organizations going digital, there is a surging increase in demand for developers who are familiar with the better-known programming languages. And as we’ve already mentioned earlier, that’s JavaScript!

What next?

As with most things, there are plenty of good resources on the web for teaching yourself JavaScript. Examples include:

Whichever route you take, make sure you spend enough time learning all the basics. And who knows in a couple of months you might be the next big thing in Tech!