Sitemap

About JavaScript

4 min readMay 5, 2021

--

Nowadays JavaScript is used by a massive number of high-profile applications, showing that deeper knowledge of this technology is an important skill for any web or mobile developer. The first javaScript creator named Brendan Eich who was an engineer of Netscape. JavaScript was first released in 1996 and it was called LiveScript and for the marketing decision, they changed the name to JavaScript. The first app was created by Microsoft which was internet explorer 3.

JavaScript has no concept for input and outputs its design to run scripting language. At that time most of the popular software was design by JavaScript such as Adobe Photoshop, Yahoo search engine, Apache CouchDB also Linux operating systems were designed by JavaScript.

String

The string is sequences of Unicode characters. For a single string here use length

Example:

‘ yogurt ’.length; / / 6

Index.of()

index.of is used to find the string numbers of a sentence and its use the Syntex of this : indexof(searchValue) and indexOf(searchValue, fromIndex). it's a case-sensitive seachValue is for the value of string if a user doesn't give a number then it gives undefined. index values are started from 0, 1, 2 … which helps to find the positions of the word. not only that it also helps to find if the word is correct or not by true false.

Slice()

it's used for extracted the section of a string for results it returns a new string without change the previous string. Slice is declared by the slice(beginIndex) and slice(beginIndex, endIndex). for example const str = ‘The Slice Brown For Goods Over the lazy cat.’

console.log(str.slice(31)); // outputs are: “the lazy cat.”

console.log(str.slice(4, 19)); // outputs are: “Slice Brown For”

console.log(str.slice(-4)); // outputs are: “cat.”

console.log(str.slice(-9, -5)); // outputs are: “lazy”

replace()

replace method have to things that's called patterns and replacement. pattern is the value or word you want to change and replacement is the new value that you want to see on the new string.for an example:

const p = ‘this is new method to learn’

console.log(p.replace(‘method’, ‘project’) // output: this is new project to learn

it also set by const regex = /method/i;

console.log(p.replace(regex, ‘task’)); // output: this is a new task to learn

toUppercase() and toLowercase()

These two methods are similar one method turns all sentence word to uppercase and the other one turns lowercase for an example:

const sentence = ‘The Dog is my Dog’;

console.log(sentence.toLowerCase()); // output: “the dogis my dog”

console.log(sentence.toUpperCase()); // output: “THE DOG IS MY DOG”

Numbers

Its built in two numeric types

  1. Number
  2. Bigint

parseInt()

For converting string to an integer used parseInt( ) function.

For an example: parseInt(‘420’, 10); // 420

parseInt(‘020’, 10); // 20

ParseInt contains first strings “ 0 ” to Octal (redux 8) and second strings as hexadecimal.

Example: parseInt(‘ 010 ’); // 8

parseInt(‘ 0x10 ’); // 16

parseInt(‘ 11 ’, 2); // 3

For converting values to numbers here use parseFloat( ) it is similar as parseInt( ).

For an example: ‘ 50 ’; // 50, ‘ 020 ’; // 20, ‘ 0x10 ’; // 16

isNaN()

In JavaScript here some special value which is called NaN. NaN means ( Not a Number)

Example: parseInt( ‘ Number’ , 20); / / NaN

Here also one special value is called Infinity. Its write as isFinite( 2 / 0 ); / / false

Ceil()

Ceil is declared in javaScript by Math.ceil() its have an specialty that its turns the interger number to a rounded number its always give an value not give a Nan error. examples Math.ceil(null) it gives integer 0 as a result.

Examples:

console.log(Math.ceil(0.89)); //output: 1

console.log(Math.ceil(4)); //output: 4

console.log(Math.ceil(7.004)); //output: 8

console.log(Math.ceil(-7.004)); //output: -7

Abs()

Abs called in javaScript is Math.abs() it returns absolute value of a numbers. Meaning it returns x if the value of x is positive or zero. and negation of x if the value of x is negative.

Examples:

function difference(a, b) {

return Math.abs(a-b );

}

console.log(difference(2, 8)); // output: 6

console.log(difference(8, 2)); // output: 6

console.log(difference(1.23456, 7.89012)); // output: 6.6555599999999995

Concat()

Its a very interesting method in javaScript, concat() method is used to merge the two or more arrays. While proceed the method it does not change the existing array but it can return a new array with sortted.

Examples:

const array1 = [‘a’, ‘b’, ‘c’];

const array1 = [‘d’, ‘e’, ‘f’];

const array1 = array1.concat(array2);

console.log(array3); //output: Array[‘a’, ‘b’, ‘c’,‘d’, ‘e’, ‘f’]

map()

The map() method is used to creates a new array with a new value of calling a provided functions on every elements in the calling array. means map() method is depended on specific array its used only when one of arrays value have to be change.

Example:

const firstArray = [1, 4, 9, 16];

const map = firstArray.map(x => x * 2);

console.log(map); // output: [2, 8, 18, 32]

--

--

No responses yet