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

Publicado em: 18 Abril 2021
no canal de: 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


Nesta página do site você pode assistir ao vídeo on-line Creating arrays in JavaScript & adding elements by using constructor and breaking string using split duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário plus2net 18 Abril 2021, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 614 vezes e gostou 1 espectadores. Boa visualização!