What does `_` mean in this example code:

```
if (_(abc.content).has("abc")){
    console.log("abc found");
}

```

Many people say "\_" means a private member, but if `abc` or `content` is a private member, shouldn't we use `_abc.content` or `abc._content`?

Thank you
['https://Stackoverflow.com/questions/53473475', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/7025179/']
For that to be valid, `_` must refer to a *function*. Perhaps the script is using [`underscore`](https://underscorejs.org/#has), in which case `_(abc.content).has("abc")` returns a Boolean - `true` if the `abc.content` object has a *key* of `abc`, and `false` otherwise:

```js
const abc = { content: { key1: 'foo', abc: 'bar' } };

if (_(abc.content).has("abc")){
    console.log("abc found");
}

console.log(_(abc.content).has("keyThatDoesNotExist"))
```

```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js"></script>
```

It probably has nothing to do with private properties, because `_` is a *standalone* function.

The library used might also be lodash:

```js
const abc = { content: { key1: 'foo', abc: 'bar' } };

if (_(abc.content).has("abc")){
    console.log("abc found");
}

console.log(_(abc.content).has("keyThatDoesNotExist"))
```

```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.core.min.js"></script>
```

But to be sure, you'll have to examine `_` - `console.log` it, or see where it's defined, to get some idea.
\_ is a valid variable name in JavaScript and can be used in any way you want just like i, a, x, length, time, date or any other variable name you can come up with.

Personally I usually use underscore as a variable in a function parameter list when I wont be using that variable in the function body.

```
const func = (_) => {
  // _ is not used in the function body
};

```

```js
const _ = () => { console.log('Hello from underscore!'); };

_();
```