## Number Methods

• toString ( )
• toExponential ( )
• toFixed ( )
• toPrecision ( )
• valueOf( )
• isFinite( )
• isInteger( )
• isNan( )
• isSafeInteger( )

## toString( )

toString ( ) method returns a number as a string in other words it converts a number into a string. We can use this method to output numbers as hexadecimal (16), octal(8), binary(2).

Syntax: –
Variable_name.toString( );

## toExponential ( )

The toExponential() method converts a number into an exponential notation.

Syntax:-
Variable_name.toExponential(y)
Where y is an integer between 0 and 20 representing the number of digits in the
notation after the decimal point. If omitted, it is set to as many digits as necessary to
represent the value.

Ex: –

## toFixed ( )

The toFixed() method converts a number into a string, keeping a specified number of decimals also rounds the decimal. If the desired number of decimals is higher than the actual number, nulls are added to create the desired decimal length.

Syntax: –
a.toFixed(y)
Where y is the number of digits after the decimal point. Default is 0 (no digits after the decimal point)

Syntax: –
a.toFixed(y)
Where y is the number of digits after the decimal point. Default is 0 (no digits after the decimal point)

Ex:-

## toPrecision ( )

The toPrecision() method formats a number to a specified length.
A decimal point and nulls are added (if needed), to create the specified length.

Syntax:-
Variable_name.toPrecision(y)
Where y is the number of digits. If omitted, it returns the entire number (without any
formatting)

Syntax:-
Variable_name.toPrecision(y)
Where y is the number of digits. If omitted, it returns the entire number (without any
formatting)

Ex:-

## Number.isNaN()

The Number.isNaN() method determines whether a value is NaN (Not-A-Number).
This method returns true if the value is of the type Number, and equates to NaN. Otherwise, it returns false.
Number.isNaN() is different from the global isNaN() function. The global isNaN() function
converts the tested value to a Number, then tests it.
Number.isNaN() does not convert the values to a Number, and will not return true for any value
that is not of the type Number.

## Number.isInteger( )

The Number.isInteger() method determines whether a value is an integer.
This method returns true if the value is of the type Number, and an integer, otherwise it
returns false.

Ex: –

## Number.isSafeInteger()

The Number.isSafeInteger() method determines whether a value is a safe integer.
A safe integer is an integer that can be exactly all integers from (2^53 – 1) to -(2^53 – 1)
This method returns true if the value is of the type Number and a safe integer.
Otherwise, it returns false.

## Two types of Comment

• Single Line Comment
• Multi Line Comment

## Single Line Comment

Text between // and the end of the line will be ignored by JavaScript.

// you can assign any type of value
var imvalue = 101;

var imvalue = 101; // assign any type of value

## Multi Line Comment

Any text between / and */ will be ignored by JavaScript.

Ex: –
/* Comment Here */

Adding // in front of a code line changes the code lines from an executable line to a comment.

var imvalue = 101;
// var imvalue = 101;

Tagged : / /

## Declaring Variable

Declaring Variable Rule

• Variable can contain a combination of letters, digits, underscores ( _ ), and
• dollar signs ( \$ ).
• Must begin with a letter A-Z or a-z or underscore or dollar sign
• Must not contain any space characters
• JavaScript is case-sensitive
• Can‟t use reserved keywords

## Declaring Variable

A variable declared without a value will have the value undefined

Tagged : / /

## What is php? Define variables and Datatypes how to use it?

In this tutorial i’m going to explore about what is PHP and their datatypes and how to use of variables.
PHP is a open-source side programming language that is specially suited for web development and can be embeded to HTML. It is powerful to hold a content management system like WordPress and can be used to control user access. PHP can actually do anything related to server-side scripting or more popularly known as the backend of a website, it is more secure and reliable to be used as a server-side scripting language.

What is DataTypes?

Datatypes is a range of all different data can be given variable in PHP. It’s supports these string.

1. String
2. Integer
3. Float (floating point numbers – also called double)
4. Boolean
5. Array
6. Object
7. NULL
8. Resource

How to write datatypes in PHP?

1. string:- string is a data type used in programming, string is a sequence of character its supports a 256-character. The simplest way to create a string is to enclose the string literal (i.e. string characters) in single quotation marks (‘), like this:

\$my_string = ‘Hello World’;

2. Integer:- An integer is a number without any decimal part.

```<?php
\$x=123;
echo \$x;
?>  ```

3. Float:- A float is a number with a decimal point as like- 2.0, 256.4, 10.358, 7.64E+5, 5.56E-5 are all floats

4. Boolean:- A boolean data can be either TRUE or FALSE. These are predefined constants in PHP.

```var_dump((bool) -2);        // bool(true)
var_dump((bool) "foo");     // bool(true)
var_dump((bool) 2.3e5);     // bool(true)
var_dump((bool) array(12)); // bool(true)
var_dump((bool) array());   // bool(false)
var_dump((bool) "false");   // bool(true)
```

5. array:- An array stores multiple values in one single variable.

<?php
\$cars = array(“Volvo”,”BMW”,”Toyota”);
var_dump(\$cars);
?>

6. Object:- Objects are the instances of user-defined classes that can store both values and functions. They must be explicitly declared.

7. Null:- Null is a special data type which can have only one value Null, if variable is created without a value it is automatically assigned a value of Null.

8. Resource:- Resources are not the exact data type in PHP. Resource is the storing the refrenece to functions call or refrences to external PHP resource as like database.

Tagged : / / /