Some JavaScript Basics

#JavaScript Number

  1. isNaN(): It’s mean is not a number.

The isNaN() method is used to determines whether a value is an illegal Number(Not a Number).

This function returns true if the value equals to NaN otherwise it returns false.

Syntax:isNaN(value);

Example:

I think this exaples clear the concepts of isNaN()

2.parseInt(): The parseInt() method parse a string and returns an integer.Lets see an example:

Syntax: parseInt(string,radix);

Example:

3.parseFloat(): The parseFloat() method parses string and returns a floating point number.

Syntax: parseFloat(string);

Example:

#JavaScript Array

1.concat(): By this we can add two or more arrays in a new array.This method doesn’t change existing array but instead returns a new array.

in this image a and b are 2 individual array by concat method we create a new aray c which is the concat array of a and b array.

2.filter():By this method we can filter the elements of the array with matching our default condition that means by this method we creates a new array with all elements that pass the test implemented by the provided function.

Example:

In this image we filter the words array with the length of 5.The new array is include the name which character length is greater then 5.

3.map():By using this method arrya is become easier to us.By using map we don’t need to use for loop to show the result of all elements of an array by using map we can use multiply or other operation in array elements lets see an example :

In this example we use for loop and map both result are same

4.push(): By this method we can insert one or more elements to the end of an array and returns the new length of the array.

Example:

In this example we push Nazim in the name array .

5.pop(): Like push method pop method works to removes the last elements from an array.

Example:

In this array we pop the last element of the name array.

#JavaScript Objects

Here we know about some important objects

  1. create() : It’s very simple we can creates a new object, using an existing object as the prototype of the newly created object.

Lets see with example:

2.assign(): It is very interesting method by which we can copy ones property to others or by this method copies all own properties from one or more source objects to a target object. It returns the target object.

example:

In this example myName objects are copied into changeName object and showed in changeObject.

3.freeze(): This object can be freezed an object .The freezed object can’t be changed after using the freeze() object.The two example will clear the concept of freeze() object.

In 1st image you can see age is showed 33 but when we use freeze() object its not changed in output.