JavaScript

Hannan Uddin Akash
6 min readNov 2, 2020

--

01. JavaScript Basics

JavaScript is a programming language that adds intuitiveness to your site. This occurs in games, in the conduct of reactions when catches are squeezed or with information passage on structures; with dynamic styling; with liveliness, and so on This article causes you begin with JavaScript and encourages your comprehension of what is conceivable.
To start, we should analyze how to add JavaScript to your page for making a Welcome world! model.

01. Go to your test site and make another organizer named contents. Inside the contents envelope, make another document called main.js, and spare it.
02. In your index.html document, enter this code on another line, not long before the end </body> tag:
<script src=”scripts/main.js”></script>
03. This is doing likewise work as the <link> component for CSS. It applies the JavaScript to the page, so it can affect the HTML (alongside the CSS, and whatever else on the page).
04. Add this code to the main.js document:

`const test= document.querySelector('h1');
test.textContent = 'Hello world!';
`
05. Ensure the HTML and JavaScript documents are spared. At that point load index.html in your program.
You should see something browser like : Hello world!

JavaScript have many kind of method. Something fell into it and it is mentioned below
1. String
2. Number
3. Boolean
4. Array
5. Object

02. JavaScript String() Method

Strings are helpful for holding information that can be spoken to in text structure. Probably the most-utilized procedure on strings are to check their length, Strings can be made as natives, from string literals, or as articles, utilizing the String() constructor
const string1 = “A string primitive”;
const string2 = new String(“A String object”);
String natives and string articles can be utilized conversely much of the time.
1. charAt() method
charAt() technique restores the character at the predefined list. The record worth should lie among start 0 and finish list length

If String length Outside the field of play Exemption file is negative or more prominent then the length of the String.

2. ConCat() method
concat is utilized to join at least two strings together in JavaScript.
string1.concat(string2, string3, string4,……, stringN)
The contentions to this capacity are the strings that should be joined together. This work restores another string that is the blend of the apparent multitude of various strings passed to it as the contention.

3. Includes() method
This method included in JavaScript determines whether the string contains the given character. If the string contains characters it will be true, otherwise it is false Note: This is case sensitive, as it distinguishes between uppercase and lowercase letters.

4. endWith() method
endsWith is used to check whether the given string ends
function is length which determines the length of the given string from the beginning to be searched for. This function returns the Boolean value.

5. indexOf() Method
indexOf finds the index of the first occurrence of the argument string in the given string. The value returned is 0-based.This function returns the index of the string (number)

6. lastIndexOf() method
This technique finds the record of the last event of the contention string in the given string. The worth returned is number based.

7. toUpperCase() method
This method converts the entire string to Upper case.
const name = 'hannan uddin';
const
output = name.toUpperCase();
document.write(output);
Output = HANNAN UDDIN

08. split() method
This technique is utilized to part the given string into cluster of strings by isolating it into substrings utilizing a predefined separator gave in the contention.

03. JavaScript Number() Method

At the point when utilized as a capacity, Number(value) changes a string or other incentive over to the Number kind. In the event that the worth can’t be changed over, it brings NaN back.
The Number constructor contains constants and techniques for working with numbers. Estimations of different kinds can be changed over to numbers utilizing the Number() work.
Number() Creates a new Number value
Number('123') returns number 123
Number("unicorn") NaN
1. Number.isNaN() Method
Number.isNaN() technique decides if the passed esteem is NaN and its sort is Number. It is a more hearty variant of the first, worldwide isNaN().
Number.isNaN(value)
value if the given true is NaN and its Number in any case given false.

2. parseFloat() and parseInt() method
parseFloat() work is utilized to acknowledge the string and convert it into a coasting point number. In the event that the string doesn’t contain a numeral worth or On the off chance that the primary character of the string is definitely not a Number, at that point it returns NaN i.e, not a number. It really restores a skimming point number parsed up to where it experiences a character that is definitely not a Number.

04. JavaScript Math() Method

1. Math.abs()
The Math.abs() technique is utilized to restore the supreme estimation of a number. It accepts a number as its boundary and returns its outright worth.

2. Math.ceil()
The Math.ceil() function in JavaScript is used to round the number passed as parameter to its nearest integer in Upward direction of rounding i.e towards the greater value.

05. JavaScript Arrays Method

In JavaScript, array is a solitary variable that is utilized to store various components. It is regularly utilized when we need to store rundown of components and access them by a solitary variable. Dissimilar to most dialects where array is a reference to the numerous variable, in JavaScript exhibit is a solitary variable that stores various components.
1. arr.sort()
The arr.sort() strategy is utilized to sort the exhibit set up in a provided request as per the look at() work. On the off chance that the strategy is excluded, at that point the cluster is arranged in rising request.

2. arr.map()
The arr.map() technique makes another exhibit with the aftereffects of called work for each cluster component. This capacity calls the contention work once for every component of the provided cluster all together.

3. findIndex()
the Array findIndex() method to find the index of positive number from an array.It doesn’t change the first exhibit.

--

--

No responses yet