Skip to Content

TheBlogReaders.com

Salesforce.com, PHP, MySQL, Javascript, Ajax, Htacces

JavaScript Interview Questions and Answers Part-4

Be First!

javascript31.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.

32.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.

33.Which built-in method sorts the elements of an array?
sort() method sorts the elements of an array.

34.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.

35.Which built-in method returns the calling string value converted to lower case?
toLowerCase() method returns the calling string value converted to lower case.

36.Which built-in method returns the calling string value converted to upper case?
toUpperCase() method returns the calling string value converted to upper case.

37.Which built-in method returns the string representation of the number’s value?
toString() method returns the string representation of the number’s value.

38.What are the variable naming conventions in JavaScript?
While naming your variables in JavaScript keep following rules in mind.

You should not use any of the JavaScript reserved keyword as variable name. These keywords are mentioned in the next section. For example, break or boolean variable names are not valid.

JavaScript variable names should not start with a numeral (0-9). They must begin with a letter or the underscore character. For example, 123test is an invalid variable name but _123test is a valid one.

JavaScript variable names are case sensitive. For example, Name and name are two different variables.

39.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.

The typeof operator evaluates to “number”, “string”, or “boolean” if its operand is a number, string, or boolean value and returns true or false based on the evaluation.

40.What typeof returns for a null value?
It returns “object”.

(157)

Previous
Next

Leave a Reply