Boost your javascript

If your mindset becomes a web developer. You must learn javascript whether you like it or not.

what is javascript?

Well, javascript is a multi-paradigm, single thread, interpreted, dynamic language with types and operators, standard built-in objects, and methods.

every programming languages have a building block. In javascript types is the main building block. Javascript’s common data types are Number, String, Object, Boolean, Function, Array, Null, Undefined and Symbol.

Today, we discuss javascript common data type Array and Array methods. Arrays are list-like objects whose prototype has methods to perform traversal and mutation operations. Neither the length of a JavaScript array nor the types of its elements are fixed. Since an array’s length can change at any time, and data can be stored at non-contiguous locations in the array, JavaScript arrays are not guaranteed to be dense; this depends on how the programmer chooses to use them. In general, these are convenient characteristics; but if these features are not desirable for your particular use, you might consider using typed arrays.

Create an Array:

One way of creating arrays is as follows:
var arr = new Array();
arr[0] = 'white';
arr[1] = 'red'
arr[2] = 'black'
console.log(arr) // ['white','red','black']
console.log(arr.length) // 3
Or A more convenient notation is to use an array literal:
var arr = ['white','red','black']
consoleg(arr.length) // 3

Add an item to the end of an Array

let animal = ['dog','cat','rat']
animal.push('cow')
console.log(animal) // ['dog','cat','rat','cow']

Remove an item to the end of an Array

let animal = ['dog','cat','rat']
animal.pop('rat')
console.log(animal) // ['dog','cat']

Add an item to the start of an Array

let birds = ['Poppy','Bruno','Chipper']
animal.unshift('Parrots')
console.log(birds) // ['Parrots','Poppy','Bruno','Chipper']

Remove an item to the start of an Array

let birds = ['Poppy','Bruno','Chipper']
animal.shift('Poppy')
console.log(birds) // ['Bruno','Chipper']

Find the index of an item in the Array

let players = ['Messi','Ronaldo','Naymer']
console.log(players.indexOf('Ronaldo')) // 1

Note: Array starts with zero indexes.

An enthusiast JavaScript and React developer.