Some important topics of JavaScript.

Tarek Mahmud
3 min readMay 6, 2021

--

  1. ParseInt: If you convert a string to an integer then you can use a build-in function parseInt().

2. Variables: you can declare a variable 3 way. let const and var.
let: allows you to declare block-level variables. The declared variable is available from the block it is enclosed in.
const: you can not change the value of this variable.
var: is the most common declarative keyword. It does not have the Limitations that the other two keywords have.

3. Operators: Javascript numeric operator are +, -, *, / and also modulo %. Values are assigned by “=”.
Tow string is adding for using the “+” operator.
'hello' + ' world'; // "hello world"
An empty string is added to convert any number to a string.
10 + ''; // "10"

4. Arrays: An array is a special object of Javascript.
One way of creating arrays is as follows:
var a = ['mango', 'banana', 'jackfrout'];
We can find out the length of an array using this method.

var frouts= ['mango', 'banana', 'watermilon'];
frouts.length; // 3

5. slice: The slice() method returns the selected elements in an array, as a new array object. we can slice a string or array using a built-in function by slice().

var myText = “Hello I am slice now my code”;
console.log(myText.slice(10));
//result: ‘ slice now my code’

6. push: The push() method adds new items to the end of an array, and returns the new length. we can push a new element using a built-in function of push().

var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.push("Kiwi");

7. pop: The pop() method removes the last element of an array, and returns that element. we can Remove and return the last item using a built-in function of pop().

var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.pop();

8. Find: we can find an element from an array using a find function. find() does not execute the function for empty arrays. find() does not change the original array.

const Number= [5, 12, 8, 130, 44];const found = Number.find(element => element > 10);console.log(found);
// expected output: 12

9. Concat: we can add two arrays by using a concat method. this method does not change the array but creates a new array.

var hege = ["Cecilie", "Lone"];
var stale = ["Emil", "Tobias", "Linus"];
var children = hege.concat(stale);
console.log(children);
//["Cecilie", "Lone", "Emil", "Tobias", "Linus"]

10. Math.random(): If we need a random number so we can use a function of Math.random(). The random() method returns a random number from 0 (inclusive) up to but not including 1 (exclusive).

Math.random();

--

--

Tarek Mahmud
Tarek Mahmud

No responses yet