Must know in JavaScript
You need JavaScript enabled to view it to be a web developer. But when you go to work, you may not have everything. But there are some things that you may need to do once in a while. Today I will discuss some such things.
Java String : you must know about the string . you can ask me what is string? it is so easy thing . String is like a sentence or word . You sayed you name “Akash”. Also sayed that you are a good student . so “ good student ” is a string .
In JavaScript you write those code . like this
const name: “Akash”;
But one day you meet a alien . He cannot understand english .But he can understand when its red color . so now you need to write a code to color your name . in JavaScript code will be like this :
const name : “ Akash”;
name.fontcolor(red);
But Alien have one brother from another mother . He can Understand red color but it font size must be 12px . Now code will be like this :
name.fontsize(12);
Alien has two mother they are from another planet . they cannot understand your name . They can only understand if you write you name with all capital word . Now code will be like this .
name.toUpperCase();
Alien father is a intelligence alien .But he also can not understand your name he can understand your name . if you bold your name . Now code will be like this .
name.bold()
Now we talk about JavaScript Number: Ever number is a JavaScript number .ha ha ah ha . yes its too easy . you can understand easily . One day you go to market alone for buy something . you go one shop and buy a pen . the pen price are 5.30 taka . But you give 5 taka and get the pen . Now shop keeper put the taka in box and read amount with float. Code will be look like this .
const pen = 5.30;
const result =math.floor(pen);
console.log(result);
result = 5;
you go an other shop and buy a paper . now its price is 25.75 taka . but this time you must give a full amount . how much price you give the shop keeper . you cannot understand . and you write a code . this will look like this .
const paper = 25.75 ;
const result = math.ceil(paper);
console.log(result) = 26
Now we talk about javaScript Array : What is array ? cool brother it is also easy . just imagine one school . Every class has different number of student .Class one has 25 student , class two has 30 student, class three has 35 student ,class four has 25 student , class five has 20 student . you put all information in one code now the code . the code look like this .
const school = [25,30,35,25,20];
One day your head teacher come and said delete class five data , by code . now your write a code like this .
school.pop()
console.log(school) =>result will be like this [25,30,35,25]
Another day minister come to your school and said just show me the all data with out class one .By code. Now you will write a code like this
school.shift()
console.log(school) => result will be like this [30, 35, 25 ,20 ]
Every year your school commute arrange a meeting . This year commute decide a add a new class like nursari .And now you have to add nursari student to your data by code . the code will be like this .
school.unshift(15)
console.log(school) => result will be like this [15, 25, 30, 35 , 25, 20 ]
A teacher say you please show me total student data from class five to class one . this time code will be like this :
school.reverse()
console.log(school) => result will be like this [20,25,35,30,25,15]
That’s for today hope you can understand easily . Next time share another topic with easy way . take love .