JavaScript
JavaScript is a scripting language. javascript syntax based on java and c.
Types of JavaScript:
1.Boolean
JavaScript Boolean only has two values, true and false.
Ex: let (5>2) //true
Let (5<0) //false
2. Numbers
Numbers can be written with or without decimals
Ex: var a = 2.50 //with decimals
Var b = 20 //without decimals
3. Strings
Strings can be any text inside double or single quotation.even a whiteSpace is also a string.
Ex: let string = “Moyuri Akther”;
Let result = string.length;
Output = 13;
Methods of strings:
- charAt() Method: charAt method returns index position
Ex: let string = “Moyuri”
string.charAt(3)
Output u
- concat() Method: Concat joint two or more strings and return a new string
Ex: let string1 = “Moyuri”
Let string2 = “Akther”
Let string3 = string1.concat(‘ ’, string2);
- includes() Method: To find out if one string is in another string use includes() method.
Ex: let string1 = “Moyuri eat rice”;
Let word = “eat”;
console.log(string.includes(‘eat’)); //true
- endsWith: This method lets you determine if one string ends with another.
Ex: let string1 = “Moyuri eat rice”;
console.log(string.endsWith(rice)); //true
4.Symbol
5.Object
6.Function
Functions are core components of javascript.we can call a function with a parameter or without parameter or more than expected parameter.
Ex: Add(); // without parameter
Add(4, 6) // with parameter
Add(3, 5, 2) // more then expected parameter
7.Array:
In JavaScript, arrays are one type of special object. An array can hold more than one value at a time. Length is a special property of the array.
Ex: var names = [‘Moyuri’, ‘Rimi’, ‘Riva’];
Ex2: var names[0] = ‘Moyuri’;
var names[1] = ‘Rimi’;
var names[2] = ‘Riva’;
9.Date
10.RegExp
Variables: JavaScript has three types of variables var, let, and const
Var: The value of any type of variable can be determined with var
Let: Let Declare the value of variables that may change
Const: Variables whose value will never be changed or redefined are declared by const
Operators: javascript operators are +, -, *, /, %
Comparisons: JavaScript comparisons are <, >, <=, >= , ==, ===, !=, !===
Determines the value by double equals. Triple equal used for comparison.
JavaScript Math:
Math.round(): math.round() returns the nearst integer number.
Ex: Math.round(4.3) // output is 4
Math.round(4.8) //output is 5
Math.ceil(): Math.ceil() converts the decimal number into the integer above.
Ex: Math.ceil(4.3) // output is 5
Math.ceil(4.8) //output is 5
Math.floor(): Math.floor() converts the decimal number into the integer below.