Javascript Push - Use Push on an Array in Javascript
i=new Array("Hi", "Hello", "Cheers", "Greetings");
i.push("Good day");
document.write(i);
Which Prints:
Hi,Hello,Cheers,Greetings,Good Day
-We
create an array and name it
i because we like REALLY short names.
-We use Javascript's built-in
push method on our array.
-We enclose what we want pushed (put on the end) in quotation marks, unless it's also a variable. (see Copy and Paste Code below)
-We use Javascript's built-in
document.write command to print to the browser.
Free Copy and Paste Javascript Code:
<script type="text/javascript">
<!--
i=new Array("Hi", "Hello", "Cheers", "Greetings");
j="Good Day";
i.push(j);
document.write(i);
-->
</script>
Resources:
Javascript Array - Create an Array in Javascript
Javascript Concat - Use Concat to Join Two Arrays in Javascript
Javascript Join - Use Join to Make an Array into a String in Javascript
Javascript Splice - Use Splice to Replace Items in an Array in Javascript
Javascript Reverse - Use Reverse on Items in an Array in Javascript
Javascript Sort - Use Sort on Items in an Array in Javascript
Javascript Shift - Use Shift to Remove Items from the Beginning of an Array in Javascript
Javascript Pop - Use Pop to Remove Items from the End of an Array in Javascript
Splitting an Array using Javascript
Javascript Unshift - Use Unshift to Put Items on the Front of an Array in Javascript
Javascript Slice - Use Slice to Get Items from an Array in Javascript
PRINT to Browser with document.write Command in Javascript
Javascript Alert
onClick Javascript
Javascript Referrer
Javascript Reset Form
Annoy Users with onBlur in Javascript
Get Query String Using Javascript
Use innerHTML to Change Text on a Page
Click HERE to comment or discuss at iLoveTheCode GOOGLE Group
| | HTML Gary B. Shelly, Th... | |
| | | |
| | | CSS David McFarland |