Ten Things A Serious JavaScript Developer Should Know
JavaScript is a high-level programming language that conforms to the ECMAScript specification. If you are a JavaScript developer, you must have to know about basic things in JavaScript.
If you are a Serious about JavaScript, Here ten things you must have to know:
1.charAt(): charAt() is a JavaScript String method that checks the position number of a character in a String. It takes input as an index number and find the character of that index position.
const sentence = ‘I am serious JavaScript Developer’;
const index = 5;
console.log(`The character at index ${index} is ${sentence.charAt(index)}`);
// expected output: “The character at index 5is s”
2. concat() : concat() is a JavaScript String method that concatenates string arguments and returns new string.
const str1 = ‘Java’;
const str2 = ‘Script’;
console.log(str1.concat(‘ ‘, str2));
//output: “Java Script”
3. includes(): includes() is a JavaScript String method which checks if there any string in another string and returns a boolean value.It is case sensitive.
const sentence = ‘I am a serious JavaScript Developer’;
const word = ‘JavaScript’;
console.log(`The word “${word}” ${sentence.includes(word) ? ‘is’ : ‘is not’} in the sentence`);
4. indexOf(): indexOf() is a JavaScript String method that returns the position value of a specified argument. In input if anyone provides a specified value then indexOf() return the position number of that value otherwise it returns -1.
const paragraph = ‘I am serious JavaScript Developer’;
const searchTerm = ‘JavaScript’;
const indexOfFirst = paragraph.indexOf(searchTerm);
console.log(`The index of the first “${searchTerm}” from the beginning is ${indexOfFirst}`);
// output: “The index of the first “JavaScript” from the beginning is 13"
5.lastIndexOf(): lastIndexOf() is a JavaScript String method that returns the position value of a specified argument searching from backwards.
6. trim(): trim() is a JavaScript String method which simple remove whitespace from both side of a string
const str = ‘ JavaScript ‘;
console.log(str);
// expected output: “JavaScript”;
7. isNaN(): isNaN() is a JavaScript method that check the input value is it is NaN and Number .
8. parseInt(): parseInt() is a JavaScript method that return any arguments value as integer number.
console.log(parseInt(‘100.50’));
//output: 100
9.parseFloat(): parseFloat() is a JavaScript method that return any arguments value as floating number and input is integer then return integer or return floating value
console.log(parseFloat(‘60.55’));
//output: 60.55
console.log(parseFloat(‘60’));
//output: 60
10. Math.abs(): Math.abs() is a JavaScript method that returns absulte value of input.
const number1 = -100
console.log(Math.abs(number1));
//output: 100
const number2 = 100
console.log(Math.abs(number2));
//output: 100