21.Which built-in method returns the character at the specified index?charAt() method returns the character at the specified index. 22.Which built-in method combines the text of two strings and returns a new string?concat() method returns the character at the specified index. 23.Which built-in method calls a function for each element in the array?forEach() method calls a function for each element in the array. 24.Which built-in method returns the index within the calling String object of the first occurrence of the specified value?indexOf() method returns the index within the calling String object of the first occurrence of the specified value, or − 1 if not found. 25.Which built-in method returns the length of the string?length() method returns the length of the string. 26.Which built-in method removes the last element from an array and returns that element?pop() method removes the last element from an array and returns that element. 27.Which built-in method adds one or more elements to the end of an array and returns the new length of the array?push() method adds one or more elements to the end of an array and returns the new length of the array. 28.Which built-in method reverses the order of the elements of an array?reverse() method reverses the order of the elements of an array − − the first becomes the last, and the last becomes the first. 29.Which built-in method sorts the elements of an array?sort() method sorts the elements of an array. 30.Which built-in method returns the characters in a string beginning at the specified location?substr() method returns the characters in a string beginning at the specified location through the specified number of characters. 31.Which built-in method returns the calling string value converted to lower case?toLowerCase() method returns the calling string value converted to lower case. 32.Which built-in method returns the calling string value converted to upper case?toUpperCase() method returns the calling string value converted to upper case. 33.Which built-in method returns the string representation of the number's value?toString() method returns the string representation of the number's value. 34.What are the variable naming conventions in JavaScript?While naming your variables in JavaScript keep following rules in mind. 35.How typeof operator works?The typeof is a unary operator that is placed before its single operand, which
can be of any type. Its value is a string indicating the data type of the operand. 36.What typeof returns for a null value?It returns "object". 37.How to create a Cookie using JavaScript?The simplest way to create a cookie is to assign a string value to the
document.cookie object, which looks like this −
document.cookie = "key1 = value1; key2 = value2; expires = date";
Here expires attribute is option. If you provide this attribute with a valid date or time then cookie will expire at the given date or time and after that cookies' value will not be accessible. 38.How to read a Cookie using JavaScript?Reading a cookie is just as simple as writing one, because the value of the
document.cookie object is the cookie. So you can use this string whenever you
want to access the cookie. 39.How to delete a Cookie using JavaScript?Sometimes you will want to delete a cookie so that subsequent attempts to read the cookie return nothing. To do this, you just need to set the expiration date to a time in the past. 40.How to redirect a url using JavaScript?this is very simple to do a page
redirect using JavaScript at client side. To redirect your site visitors to a new
page, you just need to add a line in your head section as follows −
<head><script
type="text/javascript"><!-- window.location="http://www.newlocation.com";//--> </script> </head> |