Javascript Introduction
Javascript! what is javascript? I think You know what is javascript. But you need to re-introduce it because it is notorious for being misunderstood
It’s useful to start with a brief history of the language. Javascript was created by Brendan Eich in 1995. You can see him on the image. It’s updated respectively. The major edition of the standard which published in June of 2015
Its types are…
1.String
2.Number
3.Boolean
4.Object
5.Function
6.Array
7.Null
9.Undefined
You will know about those in the next.
Javascript String
A JavaScript string stores a series of characters. Some of the most Used operations of string are charAt, concat, includes,endsWith, indexOf, lastIndexOf, replace, slice, split, startsWith, substr, toLowercase, toUppercase, trim, trimStart, trimEnd. I will discuss all of them by respective
How to create String
firstly, You need to know some characters.
· Single quotes (‘)
· double quotes (“)
· backtick (`)
const stringOne = ‘This is single quotes string’
const stringTwo = “This is double quotes string ”
const stringThree = `This is backtick string`
const stringFour = new String(“String created ”)charAt Method
You can access a character in a string by using charAt with the position of this character.
const stringOne = (“This is a string”)
const findCharacter = stringOne.charAt(3)
conse.log(findCharacter)
output = (s) //you can see in stringOne, the character in 3 position is “s”(It start with the position of 0. 0=T, h=1, i=2, s=3).Concat Method
By using the concat method, you can add two strings to one new string.
Const stringOne= “MY name is"
Const stringTwo = “Abdur Rahman”
Const result = stringOne.concat(“ ”,stringTwo)
Console.log(result)Output = My name is Abdur Rahman; //you can see the output. It added two strings by the concat method. stringOne = My name is and stringTwo=Abdur Rahman. As a result, stringOne concat with stringTwo.
indexOf( ) Method
we saw charAt. In charAt, it helps to find character or word by calling their position. But in the indexOf method, it helps us to find the position from a string by calling their character or word. let’s see the example
const stringOne = “My name is Abdur Rahman”;
const result = stringOne.indexOf(“is”);
console.log(result);
Output = 8Node
[ if string.indexOf(“lorem”) does not match with any character the output of the result will be -1].
.toLowercase( ) Method
The toLowerCase() method used to convert to the lower case of the value of the string
Const stringOng= “My name is ABDUR RAHMAN”
Console.log(stringOne.toLowerCase());
Output = my name is abdur rahman ;.toUppercase( ) Method
The toUpperCase() method used to convert to the upper case of the value of the string
Const stringOng= “my name is abdur rahman”
Console.log(stringOne.toUpperCase());
Output = MY NAME IS ABDUR RAHMAN;can you see something interesting! toLowecase() method and toUppercase() method almost same.
Slice() Method
By using the slice method, we can bring out a part of the string from the main string.
Get Abdur Rahman’s stories in your inbox
Join Medium for free to get updates from this writer.
example:
const stringOne= "JavaScript is the world's most popular programming language"console.log(stringOne.slice(25))
output = " most popular programming language"
//when you give one value the result will be after position.console.log(stringOne.slice(0,25))
output= "JavaScript is the world's"console.log(stringOne.slice(-8))
output= "language"console.log(stringOne.slice(-28, -8))
output = "popular programming "
Split() Method
This method converted a string into an ordered list by an array and it returns the array.
const stringOne = ‘JavaScript is the world most popular programming language’;console.log(stringOne.split(' '));
output = ["JavaScript", "is", "the", "world", "most", "popular", "programming", "language"]console.log(stringOne.split());
output = ["JavaScript is the world most popular programming language"]
you can also declare your output limit.
const stringOne = ‘JavaScript is the world most popular programming language’;console.log(stringOne.split(''));
output = ["J", "a", "v", "a", "S", "c", "r", "i", "p", "t", " ", "i", "s", " ", "t", "h", "e", " ", "w", "o", "r", "l", "d", " ", "m", "o", "s", "t", " ", "p", "o", "p", "u", "l", "a", "r", " ", "p", "r", "o", "g", "r", "a", "m", "m", "i", "n", "g", " ", "l", "a", "n", "g", "u", "a", "g", "e"]console.log(stringOne.split('',10));
output = ["J", "a", "v", "a", "S", "c", "r", "i", "p", "t"]
lastIndexOf() Method
We know about indexOf method which returns the first match of a string. But the lastIndexOf method returned the last value which is a match.
const stringOne = “My name is Abdur Rahman”;const result = stringOne.indexOf(“a”);
console.log(result);
Output = 4const result = stringOne.lastIndexOf(“a”);
console.log(result);
Output = 21
includes() Method
This method uses to find the value from a string. If the value matches with any string value, it returns true or if the value does not match with any string value it returns false.
const stringOne = ‘JavaScript is a programming language’;
console.log(stringOne.includes("programming"))
output= trueconsole.log(stringOne.includes("not"))
output= false
😍Javascript✌
continue…….😍





