# parseInt, parseFloat

Omar Faruq
3 min readMay 6, 2021

parseInt:

In JavaScript, parseInt() is a Number method that is used to parse a string and return its value as an integer number. Because parseInt() is a method of the Number object, it must be invoked through the object called Number.

syntax: Number.parseInt( “value” [radix]);

parseFloat:

In JavaScript, parseFloat() is a Number method that is used to parse a string and return its value as a floating-point number. Because parseFloat() is a method of the Number object, it must be invoked through the object called Number.

syntax: Number.parseFloat( “value” );

# NaN (not a number):

Unquoted literal constant NaN is a special value representing Not-a-Number. Since NaN always compares unequal to any number, including NaN, it is usually used to indicate an error condition for a function that should return a valid number.

# toLowerCase and to upperCase:

Description

LowerCase: The toLowerCase method returns the value of the string converted to lowercase. toLowerCase does not affect the value of the string itself.

upperCase: This function should simply change the case of all the alphabets present in the string to uppercase and return the new string.

# String.prototype.concat()

We can’t concatenate a string variable to an integer variable using Concat() function because this function only applies to a string,

not on an integer. but we can concatenate a string to a number(integer) using the + operator.

As we know, functions are pretty slower than operators.

functions need to pass values to the predefined functions and need to gather the results of the functions.

which is slower than doing operations using operators because operators perform operations in-line but, functions used to jump to appropriate memory locations… So, As mentioned in previous answers, the other difference is obviously the speed of operation.

# Javascript String charAt()

Javascript String charAt() is an inbuilt method that returns the new string consisting of a single UTF-16 code unit located at a specified offset into a string. The charAt() method returns a character at the specified index in the string. The index of the first character is 0; the second character is 1, and so on. If no index is provided to the charAt() method, then the default is 0.

# javascript array:

Arrays are a powerful and comprehensive tool of Javascript. They are very intuitive to use and you can do almost everything with it. However, there are important differences between arrays in Javascript and other mainstream languages.

In Javascript, there are only 6 data types defined — the primitives (boolean, number, string, null, undefined) and object (the only reference type). The array is the special object in the javascript.

Declaring an array

There are basically two ways to declare an array.

Example:

var array_1 = [ ]; …………………………..// method 1

var array_2 = new array(); …………// method 2

But generally, method 1 is preferred over method 2.

Example:

var array_1 = [“A”, “B”, “C”, “D”];

The related method with an array:

  1. a.toString() ………………each word separated by commas.
  2. a.pop() …………………… remove the last item in the array.
  3. a.push() ………………… .insert or append item in the array to the last position.
  4. a.shift() …………………….Removes and returns the first item in the array.
  5. a.reverse() ……………….. reverses the array.

--

--