10 Important things about JavaScript beginner must know
JavaScript is a high-level programming language. We can simply use this language because we don’t need to have a knowledge about machine learning. Example: If we want to use C, C++ we must know about how machine work, how a compiler does his job, how to run, how much memory uses. But we don’t need to think about this when we programmed with high Level Language as like JavaScript.
For a web developer JavaScript is essential. Past days when we could get by little HTML and CSS. But fortunately, it has some rules to dead it simple to get start:
That’s it. So Simple task can be do with just few lines of code. So, in JavaScript Programming we must know about some things:
1. We can add properties to almost everything
JavaScript has three types of data.
a. String Type
b. Numeric Type
c. Boolean Type
We can add almost all properties without undefined and null. Here we can declare a string as:
var a = “Hello”;

If the string is an object in JavaScript so we can declare that:
var string = new String(“A new String object.”);

If we want to declare a numeric type then we just simply write,
var num = 123;

If we need to declare a numeric type object then we just simply write,
var num = {id: 12, phone: 28392912};

Boolean type is just simply say that a condition is either true or false. Example:

var sleeping = true;
So here we say that anyone want to know latest status about a person. If he sleeping then he can’t disturb him. Else he talk with him.
2. Functions are objects
Many language support to make a function to take many values, but it’s depend on our background this may not be familiar with us at all.
function add(num1, num2){
if(num1 != 0){
return num1 + num2;
}
}
add (23, 34);

Here we declare a function which name is add and it has two parameter name num1, num2. We give a condition into the function, then return. At last we declare the parameter value. So it seems that we do many things as an object in the function.
3. For loop
Here a common loop for JavaScript is for loop as like as all other language. We generally use for loop to do a work to a specific time that’s we want. So, we here we need to say the starting, how long will it last, how much will with each step. That’s it. Example:
var result = [8, 3, 4, 3, 6, 7, 8, 3, 4, 5, 7, 5];
for (var i = 0; i <= result.length; i++){
var result = result + num[i];
}

We can do more thing with for loop.
4. Variable scoping
All developers, in every language, should avoid using global variables. But it’s easy to do by an accident because no other force me to organize my code in the module. Example:
var message = “Hello world”;
So here we declare a variable name message with the variable key name var which is a global variable. Global variable means we access the variable from everywhere of JavaScript code.
5. Variables that aren’t explicitly declared can be global
Suppose we remember to write our code in a function, but forgot the var keyword:
function add (num1, num2){
result = num1 + num2;
return result;
}
When we set a variable value but we don’t declare it to be a variable for the current function with var keyword the JavaScript think that we mean this.property name. Then the above code is same as like:
function add (num1, num2){
this.result = num1 + num2;
return result;
}
As a JavaScript developer, we are saying to ourselves, what’s this?
6. JavaScript is not just for browser
JavaScript is created on 1995. Now node.js allow JavaScript to run outside of any browser. Some common usages of JavaScript as a general scripting language:
a. Writing server-side code in JavaScript. Ghost.org is just one of the example of a web application whose server-side code is JavaScript running on node.js.
b. Building LESS files into CSS. Less.js id the fastest, most accurate LESS converter around, and it’s written in JavaScript. If you LESS, but don’t want your LESS to get re-translated client-side on every page load, it’s a good idea to pre-build the css by invoking the less compiler via node.js
7. Few syntax quirks
JavaScript has distinct “null” and “undefined”. Also there is both “undefined” type and value.
JavaScript has both sets of equality comparators: == and ===
We have a benefit with JavaScript that if we miss semi clone at the end of the statements, thus potentially completely changing the flow of execution.
8. Operator
JavaScript has 4 types of operator.
1. Arithmetic
2. Comparison
3. Logical
4. Assignment and conditional
Here the arithmetic operators are:
+, — * /
The comparison operators are:
==(equal), !=(not equal), > (greater than), < (less than), >= (greater than equal), <= (less than equal)
The logical operators are:
&& (logical AND), || (logical OR), ! (logical NOT)
9. Error Handling
When JavaScript developer writing code, they have to identify and repair syntax, runtime and logical errors. The most recent version of JavaScript allow developers to handle errors in many ways. Programmers can use try, catch to display custom error SMS. Almost many times programmers check their code by use console.log to see how far the code is working. And try to find out the errors. But sometimes they can’t find out errors. The programmers must understand JavaScript syntax thoroughly identify the syntax error through code review.
10. HTML DOM
The Document Object Model (DOM) is a programming interface for HTML and XML documents. Its represents the page so that programs can change the document style, structure and content. A web page is a document. This document can be either displayed in the browser window or HTML source. But it is the same document in both cases. The Document Object Model (DOM) represents that same document so it can be manipulated. The DOM is an object oriented representation of the web page, which can be modified with a scripting language such as JavaScript.
In the beginning, JavaScript and the DOM were tightly intertwined, but eventually, they evolved into separated entities. The page content is stored in the DOM and may be accessed by JavaScript. So the approximate equation is:
API = DOM + JavaScript