Why are some Javascript variables declared with underline _?

Asked

Viewed 411 times

3

Example I found on the internet:

var _iterator = require("../core-js/symbol/iterator");

var _iterator2 = _interopRequireDefault(_iterator);

var _symbol = require("../core-js/symbol");

var _symbol2 = _interopRequireDefault(_symbol);

var _typeof = typeof _symbol2.default === "function" && typeof _iterator2.default === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj; };

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

1 answer

10


It’s a convention to say that these properties are private.
Below is the link, with examples, of a style guide for Javascript:
Naming conventions

Browser other questions tagged

You are not signed in. Login or sign up in order to post.