Skip to content

Instantly share code, notes, and snippets.

@smeijer
Created August 2, 2019 17:26
Show Gist options
  • Save smeijer/e50d1dbdfa6dcb99802d2f82ca0993f4 to your computer and use it in GitHub Desktop.
Save smeijer/e50d1dbdfa6dcb99802d2f82ca0993f4 to your computer and use it in GitHub Desktop.
medium-costs-of-optional-chaining-4
var canEdit = user?.can?.edit;
var canDelete = user?.can?.delete;
// transpiles to:
"use strict";
var _user, _user$can, _user2, _user2$can;
var canEdit =
(_user = user) === null || _user === void 0
? void 0
: (_user$can = _user.can) === null || _user$can === void 0
? void 0
: _user$can.edit;
var canDelete =
(_user2 = user) === null || _user2 === void 0
? void 0
: (_user2$can = _user2.can) === null || _user2$can === void 0
? void 0
: _user2$can.delete;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment