Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a javascript equivalent to unpack sequences like in python?

Is there a javascript equivalent to unpack sequences like in python?

a, b = (1, 2)
like image 455
tback Avatar asked Jan 20 '10 10:01

tback


People also ask

How do you unpack a sequence in Python?

Introduction. Unpacking in Python refers to an operation that consists of assigning an iterable of values to a tuple (or list ) of variables in a single assignment statement. As a complement, the term packing can be used when we collect several values in a single variable using the iterable unpacking operator, * .

Is there a zip function in JavaScript?

tf. js users: if you need a zip function in python to work with tensorflow datasets in Javascript, you can use tf. data. zip() in Tensorflow.

What is a tuple JavaScript?

Tuples are a sort of list but with a limited set of items. In JavaScript, tuples are created using arrays. In Flow you can create tuples using the [type, type, type] syntax.

What is tuple unpacking in Python?

Unpacking a tuple means splitting the tuple's elements into individual variables. For example: x, y = (1, 2) Code language: Python (python)


1 Answers

[a, b] = [1, 2]

Update:

Browser compatibility matrix:

  • Firefox: all versions
  • Opera: 9.x only
  • Chrome: 49 and higher
  • MSIE: no
  • EdgeHTML: 14 (Browser version 31, released Feb. 2016)
  • Safari: 7.1 (8 for Safari Mobile)
like image 73
Antony Hatchkins Avatar answered Sep 29 '22 19:09

Antony Hatchkins