DEV Community

Farzana Pomy
Farzana Pomy

Posted on

Explore some basic concepts of javascript

What is javascript :
Javascript is a high-level interpreted language.it is usually used on the web. By
javascript change HTML and CSS. It also can update calculate and manipulate.

Today we explore javascript some data types and all types of variables.

String: String type data store and represent textual data. And we can write this inside of single or double quotes.
Some methods of string:
charAt: suppose we have a text and we file out that in any individual index which character is stored in this case we use chartAt method.
Concat: To add to the string we use this method.
Includes: if we want to check that string or number in include in array or text then we can find this using by includes method. It returns true if find this which value we find and return false if the value is not found.
endsWith: is any string value end with any keyword we can find this using by endsWith method.it returns true or false. We can verify text and length.
indexOf: A text or value store which index we can find this index value using indexOf method.
lastIndexOf: It returns the string position
replace: this method is used to replace a new string in the previous string
Slice: slice is used to cut specific text or items
Split: by split method divide a string as order and it returns an array
startsWith: we can conditionally check a string start with which word or letter. And it is return boolean value.
toLowercase and toUppercase: toLowercase used for uppercase format convert to lower.and touppercase is convert to lower case to upper.
Trim: trim method returns a new string with unexpected white space.
trimStart and trimEnd: trimStart method remove unexpected white space in start and trim end remove the end white space.

Now we explore javascript number types methods

isNaN: NaN stands for not a number. If any value wants to return number type but the value is not number then return NaN. and isNaN method is checking the value number or not. And it returns true or false.
parseFloat, parseInt: when the value is a string or anything but The expected value return value is float or int type we can convert this value parseFloat or parseInt.Or we can use MATH or Number type to convert as a Number type value.

Abs, ceil, floor, min, max, random, round, sqrt
Abs: It returns the absolute value.
Ceil: A float number will be the immediate round greatest value.
Floor: A float value return immediate less round value
Min, Max: find a maximum and minimum value between different values
Round: Round is also like ceil method.
Sqrt: This method return the squirt root values

Now we explore array methods :

Concat: Concat method used for add or sum tow array.
Find and filter: When we find any specific element in an array then we can use find the method it’s returned value and if not found then return undefined. And filter method uses almost the same as the find method. And If found the value then return an array and if not found then return an empty array.
findIndex: it checks the condition and returns the index value if not found then return -1
forEach: it is not return anything. If not found anything then returns undefined
indexOf: it returns the index value in an array
Join: this method is used for joining array elements.
Map: map creates a new array and returns this array.

lastaIndexOf: this method returns the last index and if not found it is returned -1.
Pop: the pop method used for deleting any value from the end of an array.
Push: by push, method add any element in the array.
Reduce:
Reverse: using this method can reverse all elements in an array.
Shift: using the shift method we can remove any element from an array from the start.
Slice: slice method can cut some elements from an array. this is taken start and end value.
Sort: sort method can sort the array in ascending or descending order.
Splice: using this method insert any value in any index.
Unshift: this method adds any value in the array from start.

Now we know try-catch

To Handling errors we use try-catch
In a try statement, we write our code and the catch statement can catch any error in code.

Now explore ES6:

Let's know about var, let, and const:

we can declare a variable with var. In var, the variable can be hoisting so in ES6 let and const. In let we can reassign any value if we needed and in const, we assign a value only for one time. We can not change or reassign next.

Functions with Default Parameter Values:
Sometimes functions take two or more arguments. If the user does not give one parameter it means if in function missing any parameter then we can explicitly give a default value as a parameter. it‘s called the default parameter.

template string:
Before ES6 advent we can not write multiple line strings. And it was too much difficult to implement anything as dynamical. But now using template literal we can use backticks () can write any multiple stings or it’s very easy to implement any dynamic value.

The Spread Operator:
The spread operator is used in the array. if we want to previous array element copy in the new array we can use the spread operator. All elements in the array will be copied into a new array.

Destructuring:
Destructuring can be used in an array or object.
`let a, b, rest;
[a, b] = [10, 20];

console.log(a);
// expected output: 10`
This code implements using destructuring. it means that we have some variables and we
don’t need to assign any value individually. We can easily assign any value in an array or
Object.

Arrow Functions:
=> This is the sign of the arrow function. we can store a function in a variable

Syntex:
(param1, param2, ..., paramN) => {
expression
}

In parentheses, we pass function parameter and curly bracket we write our code 
Enter fullscreen mode Exit fullscreen mode

expression.

That's all Today.Hope you enjoy it.Thank you

Top comments (0)