Share on Google+Share on Google+

Jeevan kumar
Javascript array methods
1 Answer(s)      6 years and 6 months ago
Posted in : JSP-Interview Questions

Write a Javascript code,for

  1. array element insertion from front.
  2. array element insertion from back.
  3. array element deletion from front.
  4. array element deletion from back.

Ads

View Answers

October 29, 2010 at 4:23 PM


Hello Friend,

Try this:

<script type="text/javascript">
var lang = new Array();
lang[0] = "C";
lang[1] = "Java";
lang[2] = ".NET";
lang[3] = "PERL";
document.write(lang.join("<br>"));
document.write("<br><b>Adding element 'Python' from the Front</b><br>");
lang.unshift("Python");
document.write(lang.join("<br>"));
document.write("<br><b>Adding element 'Basic' from the Back</b><br>");
lang.push("Basic");
document.write(lang.join("<br>"));
document.write("<br><b>Removing element from the Front</b><br>");
lang.shift();
document.write(lang.join("<br>"));
document.write("<br><b>Removing element from the Back</b><br>");
lang.pop();
document.write(lang.join("<br>"));
</script>

Thanks










Related Tutorials/Questions & Answers:
Javascript array methods
Javascript array methods  Write a Javascript code,for array element insertion from front. array element insertion from back. array element deletion... this: <script type="text/javascript"> var lang = new Array(); lang[0] = "C
JavaScript array methods
JavaScript array methods     ... in understanding 'JavaScript array method'. For this we are using JavaScript .../javascript">   var array=new Array();   array[0
Advertisements
JavaScript array passing
JavaScript array passing       In this section of JavaScript array tutorial we have shown an example of passing array to the methods or functions. When any array object
Javascript array
Javascript array  Write a javascript code to,(numerically) Enter the array size from the user Input the array elements from the user display the array elements reverses it and display   Hello Friend, Try this: <
JavaScript array queue
to implement Queue by using the JavaScript array methods as follows: javascript... JavaScript array queue       In the JavaScript array we can implement the Queue by using the push
JavaScript array replace element
JavaScript array replace element       In the JavaScript array there is not any...() method in our JavaScript array tutorial. For implementation of replace
create dynamic array in javascript
create dynamic array in javascript  How to create dynamic array in javascript
array_pop javascript
array_pop javascript  array_pop JavaScript and in PHP
javascript adding a value to an array
javascript adding a value to an array  How to add a value to a function argument or an array in JavaScript
JavaScript Array
JavaScript Array       JavaScript array print In the JavaScript array... and we will print them.    JavaScript array push
array in javascript - Java Beginners
array in javascript  how to initialize array in javascript and can we increase the size of array later on? is Array class in javascript ? also...://www.roseindia.net/java/javascript-array/index.shtml Hope
JavaScript split string into array
JavaScript split string into array  How to split the string into array?   <html> <head> <title></title> <script type="text/javascript"> var str = "Hello this is roseindia world
JavaScript array index of
JavaScript array index of  In this Tutorial we want to describe that makes you to easy to understand JavaScript array index of. We are using JavaScript... print the index position of India on array. JavaScript_array_indexof.html
create associative array from array javascript
create associative array from array javascript  How to create associative array from an array in JavaScript? Please suggest. Thanks
JavaScript Statement Array
JavaScript Statement Array   I need JavaScript Statements Examples in an Array.    //form <form name="form1" onsubmit="return validate(this)"> <input type="checkbox" name="names" value="Tom">Tom
JavaScript Array Clone
JavaScript Array Clone     ... and modify the properties and methods of the array. You can see in the given example... extends all native JavaScript arrays with few methods. The method arr1.clone
How to Print Array in JavaScript
How to Print Array in JavaScript In this section you will learn about Array in JavaScript. Array are important part of all programming languages. Array in JavaScript is a variable that can hold more than one value. Array is a collection
JavaScript array join
JavaScript array join     ... in understanding JavaScript array insert. For doing this code we are using JavaScript.... javascript_array_insert.html <html>   <h1>
JavaScript Copy Array
JavaScript Copy Array       The feature of coping the data of one array into another is very... Array Example</h2> <script language="javascript"> var arr1
JavaScript Array Clear
JavaScript Array Clear In this tutorial you will learn how to use the clear method in your JavaScript program. Clear() method is used to clear all... in JavaScript. You can see in the given example, we have create an instance of array which
JavaScript array prototype
JavaScript array prototype       We can add and modify the properties and methods of the array... have created few new methods which can be called by using the array object. Here
JavaScript array join
JavaScript array join     ... to understand JavaScript array join. For this we are using Java Script language...;   JavaScript_Array_join.html <html>   <
JavaScript Array Append
JavaScript Array Append     ... in javascript. To append values to an array using JavaScript, we have create a JavaScript array object "array" which contains two elements "
JavaScript array multidimensional
JavaScript array multidimensional In this Tutorial we want to describe you a code that help you in understanding JavaScript array multidimensional. For this we are using JavaScript language, This code illustrate a multidimensional
javascript array functions push
javascript array functions push var array = new Array(); var count = 0; function push(val){ array...++; } function pop(){ if(count==0) { alert("Array
JavaScript array position
JavaScript array position       In this section of JavaScript array tutorial we have to find the position of the array items. There is not any built in method in the JavaScript
JavaScript Array Contains Method
JavaScript Array Contains Method       In the given JavaScript array example, we are going... 'prototype' of Array class whenever we want to add or modify the methods
JavaScript array functions
JavaScript array functions We are going to describe How to create JavaScript Array function. Now we have created JavaScript Array function by help of HTML... functionalities of JavaScript Array. This Example shows that on loading a page invoke
JavaScript Array get key
JavaScript Array get key     ... in understanding JavaScript Array get key. For this we implement JavaScript... for loop to iterate this array.. JavaScript_Array_get_key.html
JavaScript array length function
JavaScript array length function In this Tutorial we want to describe you a code that help you in understanding JavaScript array length function. We are using  JavaScript language as scripting language. The var array instantiate
JavaScript Array
JavaScript Array: Almost every language supports array, which is a collection of similar data type, but in JavaScript scripting language it could be or could not be of same. An array could be a collection of similar or dissimilar datatype
Tutorials   
Java Spring Hibernate Struts Training why do not required application restart after jsp changes? How to use contentType Attribute in JSP? How to connect to MySQL in JSP? JSP Comment Types with example How to use ajax in jsp? How to access the database from JSP? how to show image as a link which path coming from database jsp netbeans javascript Logos on mail inbox. I want to update the multiple values of database depending on checkbox..? Please help me out.. jsp 18/04/2013 JSTL how to access element added via javascript dynamically using jsp code Electronic spreadsheets are useful in situation An E-mail protocol for storage JSP JSP JSP jsp servlets Exception: com.mysql.jdbc.Driver display data from database on selecting option of dropdownlist display data from database on selecting option of dropdownlist display data from database on selecting option of dropdownlist display data from database on selecting option of dropdownlist Jsp Query run command prompt from jsp program question for c++ please help me how to set up Netbeans for JSP 3 dropdown list from the database using JSP autocompletion in textfield fetching from database in jsp openning the pdf or doc file in same jsp EXT JS tt need coding JSp session time out how to display values from database into table using jsp how to set the class path variable in tomcat ? need help please online examination system mini project problem in writing coding. Please help me. How to read the body content of custom tag? need help...................please please help me jsp coding please. help me image upload Assertions I want to store the value of local variable into Global variable how to create customise shortcut keys in jsp?

Ads

 
Advertisement null

Ads