• +91 9723535972
  • info@interviewmaterial.com

Java Script Interview Questions and Answers

Java Script Interview Questions and Answers

Question - 91 : - How to delete an entry using JavaScript?

Answer - 91 : - The "delete" operator removes an array element, but oddly does not change the size of the array. This produces Number of days:7 Number of days:7

Question - 92 : - How to use strings as array indexes using JavaScript?

Answer - 92 : - Javascript does not have a true hashtable object, but through its wierdness, you can use the array as a hashtable. This produces days["Monday"]:Monday

Question - 93 : - How to use "join()" to create a string from an array using JavaScript?

Answer - 93 : - "join" concatenates the array elements with a specified seperator between them. This produces days:Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday  

Question - 94 : - How to make a array as a stack using JavaScript?

Answer - 94 : - The pop() and push() functions turn a harmless array into a stack This produces sixfivefour

Question - 95 : - How to shift and unshift using JavaScript?

Answer - 95 : - This produces zero one two shift, unshift, push, and pop may be used on the same array. Queues are easily implemented using combinations.

Question - 96 : - How to create an object using JavaScript?

Answer - 96 : - Objects can be created in many ways. One way is to create the object and add the fields directly. This produces aliens:[object Object] You can also use an abbreviated format for creating fields using a ":" to separate the name of the field from its value. This is equivalent to the above code using "this.". This produces aliens:[object Object]  

Question - 97 : - How to associate functions with objects using JavaScript?

Answer - 97 : - Let's now create a custom "toString()" method for our movie object. We can embed the function directly in the object like this. This produces title: Narni director: Andrew Adamson Or we can use a previously defined function and assign it to a variable. Note that the name of the function is not followed by parenthesis, otherwise it would just execute the function and stuff the returned value into the variable. This produces title: Aliens director: Cameron  

Question - 98 : - eval()?

Answer - 98 : - The eval() method is incredibly powerful allowing you to execute snippets of code during execution. This produces Population is 521,289

Question - 99 : - What does break and continue statements do?

Answer - 99 : - Continue statement continues the current loop (if label not specified) in a new iteration whereas break statement exits the current loop.

Question - 100 : - How to create a function using function constructor?

Answer - 100 : - The following example illustrates this It creates a function called square with argument x and returns x multiplied by itself. var square = new Function ("x","return x*x");


NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners