What is the equivalent of python's _ in javascript?

Rigth now, you can use array destructuring, no need for a var.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment

For example:

[,b] = [1,2];
console.log(b);

will output :

2

And the value 1 won't be assigned to any unused var.


There isn't an accepted throwaway variable naming in JavaScript like in Python.
Although, generally in the software engineering world, engineers tend to call those variables:

dummy, temp, trash, black_hole, garbage.

Use these variable namings or whatever name that will imply to the engineer reading your code that these variables have no specific use.

With that in mind, I would strongly not recommend using signs such as below as a throwaway variable:

_, $

Unless there is an explicit convention like in Python, don't use these signs as a throwaway variable, otherwise, it may interfere with other naming conventions and libraries in other languages, like the underscore and the jQuery libraries in JS.

And of course, if you find a specific use for that variable later on, make sure to rename it.