Jquery Important & Built-in Functions

Following are important JavaScript functions

Sno Method Description Example
1 charAt() Returns the value at the specified index. var str = “eenadupost”;
var res = str.charAt(0);
document.write(res);
Output = e 
returns the specified index value.
2 concat() Combines the two string. var str1 = “eenadu”;
var str2 = “post”;
var res = str1.concat(str1);
document.write(res);
Output = eenadupost 
return the new combined string.
3 each() Calls a function for each element in the array.. var arr = [ 1, 2, 3, 4, 5 ];
var str2 = “post”;
$.each( arr, function( index, value ){ document.write(value); });
Output = 12345 
4 indexOf() Return specified Value. var str = “welcome to eenadu post”;
var res = str.indexOf(“to”);
document.write(res);
Output = 8 
5 length Return string count. var str = “eenadupost”;
var res = str.length;
document.write(res);
Output = 10 
6 pop() Remove the last element from an array. var jquery_array = [“one”,”two”,”three”,”four”,”five”];
jquery_array.pop();
document.write(jquery_array);
Output = one,two,three,four 
7 push() Adding one or more elements to the end of existing array . var jquery_array = [“one”,”two”,”three”,”four”,”five”];
jquery_array.push(“six”,”seven”);
document.write(jquery_array);
Output = one,two,three,four,five,six,seven 
8 reverse() reverse the order of the element of the array. first element to last and last element to first var jquery_array = [“one”,”two”,”three”,”four”,”five”];
jquery_array.reverse();
document.write(jquery_array);
Output = five,four,three,two,one 

Leave a Reply

Your email address will not be published. Required fields are marked *