Creating arrays in JavaScript & adding elements by using constructor and breaking string using split

Опубликовано: 18 Апрель 2021
на канале: plus2net
614
1

We can declare an array by using its constructor or by breaking string using delimiter.
https://www.plus2net.com/javascript_t...
https://www.plus2net.com/javascript_t...


script = new Array();
We can add elements to this array like this .
script[0]='PHP'
script[1]='Python'
script[2]='JavaScript'
script[3]='JQuery'
Index position of first element is 0 , so here we have added 4 elements with last element at position 3.
We can display the array elements by using document.write()
document.write( script);
We can also create array by using split() method. We can specify the delimiter and break the string to create an array. If we don’t specify the delimiter then full string will be returned as single element array. If we specify the delimiter than same is used to break the string and create the array.
str=’welcome to plus2net’
a1=str.split(“”)
We can add one limit option to this split() method to restrict number of elements to be included in the created array.
a1=str.split(“”,2)
Here there will be two element in our array a1.
We can use split() to separate userid and domain part from one email address. Here we will use @ as delimiter.
#javascriptarray #javascriptcreatearray #javascriptsplitarray


На этой странице сайта вы можете посмотреть видео онлайн Creating arrays in JavaScript & adding elements by using constructor and breaking string using split длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь plus2net 18 Апрель 2021, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 614 раз и оно понравилось 1 зрителям. Приятного просмотра!