AKB Forums

Go Back   AKB Forums > Technical sections > Languages, Compilers and Interpreters > Web Development
Home Register Blogs FAQ Members List Calendar Downloads Arcade Mark Forums Read

Web Development Java/PHP/Perl/ASP and more

Troubles when posting message? Click here! :: Проблемы с отправлением сообщения? Нажмите сюда!

Reply
 
LinkBack Thread Tools Display Modes
Old Nov 8, 2004, 13:13   #1
Stalker
 
Timewind's Avatar
 
Join Date: Sep 2002
Location: Припять
Posts: 846
Rep Power: 7
Reputation: 14
Send a message via ICQ to Timewind Send a message via Skype™ to Timewind
javascript array() help needed asap

znachit tak.

unem massive
list = new Array();

ira mej lcnum em elementner tipa:
list['cat'] = "kiska";
list['dog'] = "sobachka";

banakanabar
list['mouse'] veradarcnum a UNDEFINED

vonc anem vor
list['cat'] element@!!! jnjem na X, vor eli verdarcni UNDEFINED

yete grum es list['cat'] = null; inq@ chi veranum ayl darnum a null.

ka metodner tipa splice, ban man, bayc et sax ashxatum a menak indexov.

zaranee priblagodaren
__________________
... for long you live and high you fly ...
Timewind is offline   Reply With Quote Quote selected
Old Mar 21, 2005, 12:47   #2
Младенец
 
Join Date: Mar 2005
Location: Yerevan, Armenia
Posts: 11
Rep Power: 0
Reputation: 10
The slice method creates a new array from a selected section of an array. The original array is unaffected by this but, if a string or number in one array is altered, it is not reflected in the other, whereas a change to a referenced object can be seen in both Array objects. The slice method uses the zero-based array index to determine the section out of which to create the new array. It extracts up to, but not including, the 'end' element (if no 'end' is specified, the default is the very last element). The following code creates an array called 'trees' and then displays a 'slice' of it:

Code:
trees = ["oak", "ash", "beech", "maple", "sycamore"]
document.write(trees.slice(1,4))

Output:
ash,beech,maple

If you use a negative index for the 'end', this specifies an element so many places from the end. Continuing with the above example, the following code would display the second through the third to last elements of the array:

Code:
trees = ["oak", "ash", "beech", "maple", "sycamore"]
document.write(trees.slice(1,-2))

Output:
ash,beech
yegdav is offline   Reply With Quote Quote selected
Old Mar 21, 2005, 12:49   #3
Младенец
 
Join Date: Mar 2005
Location: Yerevan, Armenia
Posts: 11
Rep Power: 0
Reputation: 10
The splice method is used to add and/or remove elements of an array returning an array of the elements removed. You first need to specify the index at which you wish to start removing elements, and the number to remove. (if 'howMany' is 0, you should specify at least 1 element to add). The following code creates an array 'cars' and then displays two elements starting with 'cars[1]':

Code:
cars = ["Mercedes", "Ford", "Chrysler", "Honda", "Volvo"]
document.write(cars.splice(1,2))

Output:
Ford,Chrysler

You can also include optional new elements to replace the ones removed. Expanding on the previous example, the following code would create an array consisting of the two extracted elements "Ford" and "Chrysler", but replace them with "Citreon" in the original array:

Code:
cars = ["Mercedes", "Ford", "Chrysler", "Honda", "Volvo"]
removed_cars = cars.splice(1, 2, "Citreon")
document.write(removed_cars + "<BR>")
document.write(cars)

Output:
Ford,Chrysler
Mercedes,Citreon,Honda,Volvo
yegdav is offline   Reply With Quote Quote selected
Old Mar 21, 2005, 13:19   #4
...overwined...
 
noone's Avatar
 
Join Date: Mar 2003
Location: ...tortuga...
Posts: 3,394
Rep Power: 6
Reputation: 143
list['cat'] = 'undefined';

__________________
...let's be gods... let's by ugly...
noone is offline   Reply With Quote Quote selected
Old Mar 21, 2005, 13:22   #5
...overwined...
 
noone's Avatar
 
Join Date: Mar 2003
Location: ...tortuga...
Posts: 3,394
Rep Power: 6
Reputation: 143
...если уж нравиться проверять на андефайнд...
я обычно на нулл и на ундефайнд проверяю....
__________________
...let's be gods... let's by ugly...
noone is offline   Reply With Quote Quote selected
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
add Javascript code at runtime greka Web Development 0 Aug 12, 2004 14:36
[java] Read return value of JavaScript greka Web Development 0 Jun 18, 2004 13:49
JavaScript: working with forms Aram Ghazanchyan Web Development 1 Feb 12, 2004 10:17
URGENT: WebMaster needed! dolphin Jobs 1 Jun 4, 2003 12:57
PHP Developer needed Pit Jobs 2 Mar 26, 2003 10:19


All times are GMT. The time now is 18:55.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
This board was founded on September 29, 2001
Powered by Viper Internet

Affordable Web Hosting | ParevNet

Buy text link