Skip to content

Commit 214c430

Browse files
committed
added another example on creation of lists/arrays
1 parent b75d224 commit 214c430

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

source/lists-arrays.qq

+16
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,25 @@
2020
\python
2121
my_list = [3, 2, 10, "Hello"]
2222
\out my_list
23+
\python
24+
my_list = list('Hello!')
25+
\out my_list
2326
\js
2427
var my_array = [3, 2, 10, "Hello"];
2528
\out my_array
29+
\js
30+
var my_array = new Array(1, 2, 3, "Hello");
31+
\out my_array
32+
var my_array = new Array(4);
33+
\out my_array
34+
var my_array = new Array("4");
35+
\out my_array
36+
var my_array = new Array("Hello!");
37+
\out my_array
38+
\comment \lang ru
39+
В JavaScript массивы можно создавать, используя конструктор new. Если конструктор получает в качестве аргумента одно целое число, то это число принимается за длину массива, который нужно создать. В иных случаях (несколько аргументов, аргумент-строка) создается массив, элементами которого являются перечисленные аргументы.
40+
\comment \lang en
41+
In JavaScript, one can use 'new' constructor to create an Array. If the constructor receives an integer as the only argument, that integer is interpreted as the length of a newly created Array. In other cases (several arguments, one string argument), the arguments become the elements of a newly created Array.
2642
\compare
2743
\id index-access
2844
\what \lang ru

0 commit comments

Comments
 (0)