Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/327.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在python中,我可以编写myarray[:3]来处理列表中的元素。在javascript或node中可以吗?_Javascript_Python_Arrays_Programming Languages - Fatal编程技术网

在python中,我可以编写myarray[:3]来处理列表中的元素。在javascript或node中可以吗?

在python中,我可以编写myarray[:3]来处理列表中的元素。在javascript或node中可以吗?,javascript,python,arrays,programming-languages,Javascript,Python,Arrays,Programming Languages,我就是不知道如何“翻译”成javascript 使用节点12.9.0 #in python l = [1,2,3] l = l[1:] #This is tail l = l[:: -1] #For some reason this reverses the list 要获得“尾巴”: 要获得“顶部”: 要反转: l = l.reverse(); l = l.slice(0, 3); // Equivalent to l = l[:3] l = l.reverse();

我就是不知道如何“翻译”成javascript

使用节点12.9.0

#in python
l = [1,2,3]
l = l[1:] #This is tail
l = l[:: -1] #For some reason this reverses the list
要获得“尾巴”:

要获得“顶部”:

要反转:

l = l.reverse();
l = l.slice(0, 3); // Equivalent to l = l[:3]
l = l.reverse();