JavaScript core concepts:

charAt: This method returns a new string consisting of the single UTF-16 code unit. If the index is out of range, charAt() returns an empty string. If the index can’t be converted into an integer or no index is provided then its default value will be 0.Because the first character of the string is returned.

concat: It returned those value which is included into the variable. Then when you console.log anything the value of your variable joins with the console at first. Like this:-

let name = ‘Fahim, ‘
console.log(name.concat(‘will’, ‘. eat pizza.’))
// Fahim will eat pizza.

includes: The name is very familiar to us. Includes means anything inside in a sentence, a word, or anything. If anybody says ‘twinkle twinkle little star how I wonder what you are’ and asks you which word is included and exclude into this sentence. I think you will be available to answer it very easily. Let’s see some code.

const sentence = ‘twinkle twinkle little star how I wonder what you are’;

const word = ‘twinkle’;

console.log(`The word “${word}” ${sentence. includes(word) ? ‘is’ : ‘is not’} in the sentence`);
//’The word “twinkle” is in the sentence’.

But if your selected word is not included in the sentences the result will be: // The word “which excludes” is not in the sentences.

slice: slice means to cut down those words where you use them. If you are writing a sentence like this const truth = ‘never tell a lie’ and want to slice some words from this. You should use console.log(truth. slice(5)); then your result will be ‘ tell a lie.’

toLowerCase: It is a very simple method. If you are at least low-literate then the name is very familiar for you. lowerCase gives us if all sentences will UpperCase like this const provad= ‘NOBODY BELIEVES A LIAR Never Trust Him/Her.’ If you want to make it lower case just type console.log(provad.toLowerCase());

trimStart: It is a method which is vanished the white space which is used at the beginning of a sentence. For example:-

const tell = “ How are you! “;

console.log(tell);
// output: “ How are you! “; [note: there is a white space in the beginning].

console.log(tell.trimStart());
// output: “How are you! “ ; [note: there is no white space in the beginning].

Math.abs: The Math.abs() function returns the solid value of a number. That is it returns ‘a’ if ‘b’ is positive or zero, and the negative of ‘a’ if ‘b’ is negative. If you want to get an absolute result then use the Math.abs() method.

NaN: NaN means Not a Number. If you declared a function without a number like ‘ where are you? I am in London’ then you see an output, NaN. Also, you would use ‘500c’ you will see the same result. You should use 500 for a valid results.

Array.concat: The concat() method is used to merge arrays two or more. This method does not change the existing arrays, but instead returns a new array which is plus your entire array. Like this:-

const first = [‘Khalid’];
const second = [‘Mahmud’];
const third = [‘Pilot’];
const full = first.concat(second, third);
console.log(full);
//output [ ‘Khalid’, ‘Mahmud’, ‘Pilot’ ]

Array. map: map calls a provided callback function once for each element in an array, in order, and constructs a new array from the results. The callback is invoked only for indexes of the array which have assigned values (including undefined).

Array.push: The push method adds more item to the end of an array and return a new length of the array. Example:-

const foods = [‘pizza’, ‘soup’, ‘burger’];
foods.push (‘grill’, ‘sandwich’);
console.log(foods)
//output is
5
[ ‘pizza’, ‘soup’, ‘burger’, ‘grill’, ‘sandwich’ ]

Array.shift: This method remove the first element from an array. For example:-

const paid = [100, 245, 635];
const unpaid = paid.shift();
console.log(paid);
//output [ 245, 635 ]

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Tanvir Hossain Fahim

Tanvir Hossain Fahim

2 Followers

Never say no. If you don’t know then say I will try.