An ultimate guide to JavaScript
Tags: javascript, beginners
Published: 2021-02-10 05:43:05

**ABOUT**
_This is all about brushing up your skills in JavaScript if you are a person who is working around JavaScript and wanted to brush up your skillset with its amazing power or you are a person who is searching one place where you can call up your concepts, this blog is for you.
Listing down all amazing facts which we need to know when start writing code in JavaScript, here we go-_

1.It is Developed by brandon eich in 1995, for adding interactivity in Netscape, its first name was mocha then livescript then JavaScript.

2.After JavaScript Microsoft also came up with JScript which was the reverse engineered version of JavaScript.

3.This causes pain for developers to design pages that work well on IE and Netscape than JavaScript was standardized by ECMA international in 1997 and ECMASCRIPT or ES.

4.JS is dynamically typed or loosely types so we do not have to declare the data type, it has 6 primitive values and 1 object i.e., number, string, Boolean, null, undefined and ES6 added symbol, Everything else is an Object type.

5.IF you will not add semicolon JS will add it but in some cases it will leads to unexpected results so just to play safe we should add it

6.In JS if you created a variable and not assigned any value then it will be undefined not a garbage value, if we don’t know the value then we can assign null that means we don't have a value right now.

7.typeOf(null) will not be a null, it will be an object which is a bug in JavaScript.

8.Since JavaScript is a weakly-typed language, values can also be converted between different types automatically, and it is called implicit type coercion. It usually happens when you apply operators to values of different types, and if a developer expresses the intention to convert between types by writing the appropriate code, like Number(value), it’s called explicit type coercion.

9.If you have made a function with arguments and providing fewer Arguments will be undefined and greater will be ignored.

10.Hoisting is JavaScript's default behavior of moving all declarations(functions and variables) to the top of the current scope.
Hoisting does happen in case of const but its different in case of const you can not access const variable until and unless at runtime there declaration and definition is reached.

11.As we all know we can access object properties using square or dot notation but There are certain situations where we can use square notation to access objects and rather than dot notation.
Like in case of invalid key name or key name starting with number.

12.In JavaScript arrays are objects it means you can add key value pair where keys will be indexes and value will hold property and one more fact that all the indexes if they are numbers, JavaScript automatically converts it into the string for you, you can access values like arr[0] or arr[‘a’].

13.Another fun fact is that array length is calculated as the highest index number+1 and you can add any dynamic property to it anytime and all the undefined indexes of the array are like empty places, not garbage like other languages.

14.You can write JavaScript code within the script tag just makes sure that in JS code if you are trying to access elements the those elements are there on the page because if we trying to access those elements before they have been rendered then we will get null in that case, which is why we placed the script tag towards the end of the HTML documents so that everything you need for that code is present.

15.We can use IIFE(Immediately invoked function expression)  is a JavaScript function that runs as soon as it is defined, it can be used as a solution if we don’t want to clash global variables or functions in two files with the same name.

16.Closures is a concept of a combination of function and the lexical environment of which the function was created.
or we can say closure is a function that remembers its outer variables and can access them, and all functions in JavaScript are closures.

17.The purpose of "use strict" is to indicate that the code should be executed in "strict mode", the normal, non-strict mode of JavaScript is sometimes referred to as sloppy mode.

18.There are 4 ways to invoke a function in JavaScript
i)invoking a function as a function as we always do.
ii) Invoking a function as a method means creating an object and function inside it and calling it using an object.
iii) Invoking a function with a function constructor.
iv) Calling a function via call and apply.

19.Logical operators in JavaScript, unlike operators in other programming languages, do not return true or false. They always return one of the operands.

20.Scope chain-JavaScript engine also uses Scope to find variables, if the JavaScript engine does not find the variable in local scope, it tries to check for the variable in the outer scope. If the variable does not exist in the outer scope, it tries to find the variable in the global scope.

21.Functions that are used as an argument to another function are called callback functions.

22.In JavaScript, functions are treated as first-class citizens, they can be used as an argument of another function, can be returned by another function and can be used as a property of an object.

23.The event.preventDefault() method stops the default action of an element from happening.

24.In JavaScript, there is a special constructor function known as Object() is used to create and initialize an object. The return value of the Object() constructor is assigned to a variable. The variable contains a reference to the new object. We need an object constructor to create an object “type” that can be used multiple times without redefining the object every time.

25.Hoisting as a concept which exists in JavaScript functions, classes are special functions and hoisting will not work in this case.

These were 25 facts which I feel we all should know as developers about JavaScript.