Little glimpse of Javascript features

Introduction:
Javascript is asynchronous, single-threaded, non-blocking scripting language which sometime appears as a toy in the initial stage but it has huge root under the ground. That’s why it is a must for web developers for building high profile applications. It has destined to run as a scripting language in hosting environment like browser.
History:
Javascript was created by Brendan Eich who was an engineer at Netscape in 1995. Early, it was called Livescript. But due to utilize the popularity of Java it was renamed Javascript later. This creates the all source of confusion although this to language have very few in similarity. After several years Netscape gives Javascript to Ecma International which gives a new look to Javascript as ECMAScript 3(ES3) in 1999, ES5 in 2009 and ES6 as a major edition in 2015.
Overview of some specific Javascript features:
1. Hidden truth about integer:
There is no such thing as integer. Every integer explicitly appears as a integer but implicitly it’s a float.

2. parseInt( ) and parseFloat( ):
parseInt(value, base) converts a string to number and takes two parameter value and number base(line 1,2).

If you put ‘0’ before value like ‘011’ it gives 11 as normal output but if you put ‘0x’ before value like ‘0x11’ it gives 17. But why? Because ‘0x11’ is considered as hexadecimal number.

parseFloat(value, base) uses 10 base number system as default(line 5).

Unary operator can also be used to convert a string to a number(line 6).

Difference between parsing string with parseInt or parseFloat and unary operator is parseInt or parseFloat parse upto a point where number format is not valid returns the valid format. On the other hand, unary operator returns NaN(not a number if anything other than number is in the value otherwise returns the number).

3. isNaN( ) and isFinite( ):
A special value NaN (Not a Number) is returned if the value is not a number. If any operator is made with NaN it also gives NaN. isNaN( ) method is used to check whether it’s NaN or not.

Infinity and -Infinity are the two special values which are derived from anyNumber/0 and -anyNumber/0. isFinite( ) method is used to check a number whether it’s finite or not.

4. String
String is a series of unicode characters. In a precise manner, it’s a series of UTF-16 code units and each code units has 16-bit number.
Some Useful methods and objects:
str.length => returns length of string
str.toUpperCase => make all letters uppercase
str.toLowerCase => make all letters lowercase
str.charAt(index) => returns a character at the mentioned index position
str.includes(search string) => returns true or false if the search string is in the existing string or not

str.replace(old string, new string) => returns string with the partial replaced string.

5. Null vs Undifined:
Null is a value which represents for non-value and only accessed by null keyword. Undefined is a value of type undefined which represents a variable without assigning value and it’s actually a constant.
6. Trim the white space with trim( ), trimStart( ) and trimEnd( ):
trim( ) method removes the white space in the beginning and end of the string. But trimStart( ) only removes the beginning white space of string and trimEnd( ) removes only the ending white space.

7. Truthy vs Falsy value:
false, 0, empty string(“ ”), NaN, null, undefined are called falsy value. And all other value except above are called truthy value.
One things to keep in mind. Falsy values doesn’t literaly means boolean false because it contains 0, empty string etc. which are not really boolean false but falsy value.

8. Let’s find Scope
Scope is the area where it is accessible or visible.
8.1 Global Scope
There is only one global scope in the Javascript Document and this is area outside all functions are declared. All variables declared in this scope is visible everywhere.

8.2 Local Scope
When a variable is declared inside function, it’s called local variable and it is only accessible to it’s local scope of that function.

Local Scope can be classified into two categories which are Function Scope and Block Scope (introduced in ES6 with new ways to declare variable with let and const keywords)
8.3 Function Scope
Accessibility of a variable only within function which is declared inside is called Function scope. var keyword is example for function scope accessiblity within function.

8.4 Block Scope
Area within any curly braces whether it is if-else or for loop is called block. let and const keywords are used to declare variable inside corresponding block scope.

8.5 Lexical Scope
It indicates the accessibility of children to use their corresponding parent scope variables. It bounds within the context of their parent scope.

let and const is used for block scope and var is used for function scope. Function scope is accessibility area within function and block scope is within curly braces.
9. Do some math with javascript
Math.abs(x / y) => returns absolute value of x/y.
Math.min(1, 3, 5) => returns smallest value that passed into it.
Math.max(1, 3, 5) => returns largest value that passed into it.

Math.ceil(x / y) => returns round value of next largest integer of x/y. if null is given as input Math.ceil(null) returns 0 not NaN.
Math.floor(x / y) => returns round value of previous largest integer of x/y.

10. every( ) vs filter( ) vs find( ) :
every( ) checks all values in an array according a condition whether it fullfills or not and returns a boolean value.
filter( ) checks all values in an array and returns the values within a new array which fullfills a special condition given to it.
find() checks the values in an array according a given condition and returns the first value that fullfills it in this array.

11. pop( ) vs shift( ) and push( ) vs unshift( ):
pop( ) removes the last element from an array and shift( )removes the first element from an array. Both of those returns the removed item.

push( ) adds a value to the end of an array and unshift( ) adds a value to the beginning of an array. Both of those returns the new length of the array.
