Tuesday, 29 March 2016

     The toExponential() method returns a string representing the Number object in exponential notation.

Parameters
fractionDigits
     Optional. An integer specifying the number of digits after the decimal point. Defaults to as many digits as necessary to specify the number.
Returns

     A string representing a Number object in exponential notation with one digit before the decimal point, rounded to fractionDigits digits after the decimal point. If the fractionDigits argument is omitted, the number of digits after the decimal point defaults to the number of digits necessary to represent the value uniquely.

     If you use the toExponential() method for a numeric literal and the numeric literal has no exponent and no decimal point, leave a space before the dot that precedes the method call to prevent the dot from being interpreted as a decimal point.

     If a number has more digits than requested by the fractionDigits parameter, the number is rounded to the nearest number represented by fractionDigits digits. See the discussion of rounding in the description of the toFixed() method, which also applies to toExponential().

Throws

RangeError
     If fractionDigits is too small or too large. Values between 0 and 20, inclusive, will not cause a RangeError. Implementations are allowed to support larger and smaller values as well.
TypeError
     If this method is invoked on an object that is not a Number.

Syntax

   numberobject.toExponential([fraction_digit]);
Example

var numObj = 77.1234;
console.log(numObj.toExponential());  // logs 7.71234e+1
console.log(numObj.toExponential(4)); // logs 7.7123e+1
console.log(numObj.toExponential(2)); // logs 7.71e+1
console.log(77.1234.toExponential()); // logs 7.71234e+1
console.log(77 .toExponential());     // logs 7.7e+1


Example Program:- (Editor)


Editor is Loading...

Advertisement

     The Math.min() function returns the smallest of zero or more numbers. min() is a static method of Math, you always use it as Math.min(), rather than as a method of a Math object you created (Math is not a constructor).

     If no arguments are given, the result is Infinity.
     If at least one of arguments cannot be converted to a number, the result is NaN.

Syntax

   Math.min([value1,value2,...]);
Example

   Math.min(20,50,36,2);  //2
   Math.min(-3,3,0,99);  //-3


Example Program:- (Editor)


Editor is Loading...

Advertisement

     The Math.max() function returns the largest of zero or more numbers. max() is a static method of Math, you always use it as Math.max(), rather than as a method of a Math object you created (Math is not a constructor).

     If no arguments are given, the result is -Infinity.
     If at least one of arguments cannot be converted to a number, the result is NaN.

Syntax

     Math.max([value1,value2,value3,...]);
Example

Math.max(50, 10);   //  50



Math.max(-1, -200); // -1



Math.max(-999, 2);  //  2


Example Program:- (Editor)


Editor is Loading...

Advertisement

     The Math.floor() function returns the largest integer less than or equal to a given number. floor() is a static method of Math, you always use it as Math.floor(), rather than as a method of a Math object you created (Math is not a constructor).

Syntax

   Math.floor(value);
Example

   Math.floor( 40.95); //  40
   Math.floor(-48.95); // -49


Example Program:- (Editor)


Editor is Loading...

Advertisement

     The Math.random() function returns a floating-point, pseudo-random number in the range [0, 1] that is, from 0 (inclusive) up to but not including 1 (exclusive), which you can then scale to your desired range. The implementation selects the initial seed to the random number generation algorithm; it cannot be chosen or reset by the user.

Note:  Math.random() does not provide cryptographically secure random numbers. Do not use them for anything related to security. 

Syntax

   Math.random();
Example

   Math.random();  //0 to 1 Numbers

   (Math.floor(Math.random() * 100) + 1) // 1 to 100 Numbers


Example Program:- (Editor)


Editor is Loading...

Advertisement

     The Math.round() function returns the value of a number rounded to the nearest integer. If the fractional portion of number is 0.5 or greater, the argument is rounded to the next higher integer. If the fractional portion of number is less than 0.5, the argument is rounded to the next lower integer.

     Because round() is a static method of Math, you always use it as Math.round(), rather than as a method of a Math object you created (Math has no constructor).

Syntax

   Math.round(number);
Example

Math.round(19.39); //19

Math.round(19.7); //20

Math.round(-19.04); //-19

Math.round(-19.51); //-20


Example Program:- (Editor)


Editor is Loading...

Advertisement

     The Math.ceil() function returns the smallest integer greater than or equal to a given number. ceil() is a static method of Math, you always use it as Math.ceil(), rather than as a method of a Math object you created (Math is not a constructor).

Syntax

   Math.ceil(number);


Example

   Math.ceil(.97);   // 1

   Math.ceil(0.3);     // 1

   Math.ceil(3);     // 3

   Math.ceil(7.003); // 8


Example Program:- (Editor)


Editor is Loading...

Advertisement

Sunday, 27 March 2016

Math.abs()    - The Math.abs() function returns the absolute value of a number.
Math.pow()  - The Math.pow() function returns the base to the exponent power, that is, baseexponent.
Math.sqrt()   - The Math.sqrt() function returns the square root of a number.




Example Program:- (Editor)


Editor is Loading...

Advertisement

Saturday, 26 March 2016

     The JavaScript Array object is a global object that is used in the construction of arrays; which are high-level, list-like objects.

Example

var ar=[1,2,3,4,5];


Example Program:- (Editor)


Editor is Loading...

Advertisement

     The Array.isArray() method returns true if an object is an array, false if it is not. It will check the specified value is array or not, if it is array return true value and if not return false.

Syntax

   Array.isArray(variable or value);
Example

   var ar=[10,20,30];
   alert(Array.isArray(ar));


Example Program:- (Editor)


Editor is Loading...

Advertisement

     The toString() method returns a string representing the specified array and its elements. The Array object overrides the toString method of Object. For Array objects, the toString method joins the array and returns one string containing each array element separated by commas. For example, the following code creates an array and uses toString to convert the array to a string.

Syntax

   Array.toString();

Example

   var ar=[10,20,30];
   alert(ar.toString());


Example Program:- (Editor)


Editor is Loading...

Advertisement

          The join() method joins all elements of an array into a string. The string conversions of all array elements are joined into one string. If an element is undefined or null, it is converted to the empty string.

Syntax

   Array.join();

Example

   var ar=[10,20,30];
   alert(ar.join('#'));


Example Program:- (Editor)


Editor is Loading...

Advertisement

     The pop() method removes the last element from an array and returns that element.

     pop() is intentionally generic; this method can be called or applied to objects resembling arrays. Objects which do not contain a length property reflecting the last in a series of consecutive, zero-based numerical properties may not behave in any meaningful manner.

If you call pop() on an empty array, it returns undefined.

Syntax

     Array.pop();

Example

     var ar=["1st","2nd","3rd","4th"];
     ar.pop()


Example Program:- (Editor)


Editor is Loading...

Advertisement

Tuesday, 22 March 2016

     In the following example, I want to fill the name exactly 20 characters, if the character count is exceed 20 character remove remaining character and if the character is lesser than 20 character fill with blank space(left aligned).

Example
  SELECT convert(nvarchar(20),LEFT(CONVERT(NVARCHAR, 'Merbin Joe') + SPACE(20), 20)) Name

This will produce
 Merbin Joe
Left align with fixed number of characters





But you can't able to see the blank space's so you should need to identify the space using [] or other way.

SELECT quotename(convert(nvarchar(20),LEFT(CONVERT(NVARCHAR, 'Merbin Joe') + SPACE(20), 20))) Name

quoutename in sql






Monday, 21 March 2016

     The shift method removes the element at the 0'th index and shifts the values at consecutive indexes down, then returns the removed value. If the length property is 0, undefined is returned.

Syntax

     Array.shift()
Example

     [1,2,3,4,5,6].shift()

Example Program:- (Editor)


Editor is Loading...

Advertisement

Saturday, 12 March 2016

     In the following example we showing how to move the content one place to another place using drag/drop concept in jQuery.


Example Program:- (Editor)


Editor is Loading...

Advertisement