����� 2
�� 4: ����� split.
���� �� ����� ������ �������� �"� �� ����, ��� ���"� ����� �- split. ���� ��� �� ����� ���� �������� �"� ���� � ����� split ����� ����� �� ���� �� ��� �� �� ��� ������ ����� (�� �������). ������:
var my_friends = "trixie,moxie,sven,guido,hermes";
var friend_array = my_friends.split(",");
for (loop=0; loop < friend_array.length; loop++)
{
document.writeln(friend_array[loop] + " is my friend. ");
}
���� ���� �� ������� my_friends ����� �� ����� ������� (������� JavaScript ����� ������ ���� �� ����� ��������, �� ���� ��� ������ ���� new array() �� ��� ����� ���� ������).
���� ����� ������� �����, ����� ������ ���� ����� �������� �� �� ��� �� �� ��� ������. �� ������ ������� �� ������ ���� ���� ��, ���� ����� ���� ������ ������ - ����� 1.
���� ������ �- split �� ��� ����� �� ���� �- domains ���� ��� ����:
var the_url = prompt("What's the URL?","");
var first_split = the_url.split("//");
var without_resource = first_split[1];
var second_split = without_resource.split("/");
var domain = second_split[0];
���� ���� ����, ��� �����, ����? ��� ������ �������:
var the_url = prompt("What's the URL?","");
��� ����, ���� URL:"http://www.webmonkey.com/javascript/index.html".
var first_split = the_url.split("//");
������ ����� �� ������� ���� �����: first_split[0]="http:" �- first_split[1]= "www.webmonkey.com/javascript/index.html".
var without_resource = first_split[1];
���� ������ �� ���� ����, �����: without_resource= "www.webmonkey.com/javascript/index.html."
var second_split = without_resource.split("/");
����� �� ����� �� without_resource ������ �����: www.webmonkey.com, javascript, �- index.html. ���� �� ��� split �����?
var domain = second_split[0];
���, �� ����� ��� ����� ��� ���� �� ������ ������ �� ����� second_split �������.
���� ���� ������ ��� ���� ���� ����� ������, ���� ����� ���� ��� ������ ���. ��� ����� ���� ���� ���� �� split � �� ��� ���� ������ ������� ����.
�����, ������ �� �� ������� �������� ������ ��������, �� ����� ����. �� ��� ���� �� �� ��� ����� �����. �� ����� ����. ����� ���� �����. ����? �� ���� ���� ����� ��� ��� ��� ���� ������ ����� �- cookies: ������ �����������.
���� ������ ���
��� ��� «--
|