10 things, You need to know to be a javascript Developer
JavaScript was created in 1995 by Brendan Eich while he was an engineer at Netscape. JavaScript was first released with Netscape 2 early in 1996.
10 Basic knowledge about javascript:
JavaScript number
The JavaScript number object enables you to represent a numeric value. It may be integer or floating-point. JavaScript number object follows IEEE standard to represent the floating-point numbers.
By the help of Number() constructor, you can create number object in JavaScript. For example:
var n=new Number(value);
JavaScript Array
JavaScript array is an object that represents a collection of similar type of elements.
There are 3 ways to construct array in JavaScript
- By array literal
- By creating instance of Array directly (using new keyword)
- By using an Array constructor (using new keyword)
Javascript Function
Before, using a user-defined function in JavaScript we have to create one. We can use the above syntax to create a function in JavaScript. A function definition is sometimes also termed as function declaration or function statement.
Below are the rules for creating a function in JavaScript:
- Every function should begin with the keyword function followed by,
- A user defined function name which should be unique,
- A list of parameters enclosed within parenthesis and separated by commas,
- A list of statement composing the body of the function enclosed within curly braces {}.
Example:
function
multiply(num1, num2)
{
return
num1 * num2;
}
JavaScript Objects
Objects in JavaScript, just as in several distinct programming languages, can be linked to objects in real life. The idea of objects in JavaScript can be comprehended with real-life, tangible objects. Today in this JavaScript tutorial series of DataFlair we will explain one of the major topic that is JavaScript Object. The reason why JavaScript Objects are so important is that JavaScript design depends on a simple object-based paradigm. But unlike C++ or Java, we don’t create any classes. We create objects directly because JavaScript is a template-based rather than class-based.
JavaScript Map Method
The JavaScript map() method returns a newly created array with the results of invoking the callback function on each element of the array.
The array elements are traversed from left to right in order, calling the callback function on each element.
var number = [1,2,3,4,5,6,7,8,9,10];
number.map(function(value){
return Math.pow(value,2);
});
console.log(number);
JavaScript indexOf
akes an item(and optional start) and returns the Index or -1.
const numbers = [1, 2, 3, 4, 5]numbers.indexOf(2)
numbers.indexOf(9)
JavaScript find
takes a predicate and returns the first matching item or undefined.
const numbers = [1, 2, 3, 4, 5]
const isEven = number => number % 2 === 0
const isLessThanZero = number => number < 0numbers.find(isEven) //=> 2
numbers.find(isLessThanZero) //=> undefined
JavaScript Slice
The JavaScript array slice() method is used to return a new array containing the copy of the part of the given array.
Note: Original array will not be modified. It will return a new array.
array.slice(start,end)