Skip to content

Instantly share code, notes, and snippets.

@alecat88
Created March 2, 2022 00:02
Show Gist options
  • Save alecat88/457361fb395fb0c121c4623ae4310b12 to your computer and use it in GitHub Desktop.
Save alecat88/457361fb395fb0c121c4623ae4310b12 to your computer and use it in GitHub Desktop.
ES12
// In the example, the &&= will check if the filesCount is true.
// If true, then the right value will be assigned to the left variable.
let myFiles = {filesCount: 100, files:[]};
myFiles.filesCount &&= 5;
console.log(myFiles); // This will print: {filesCount: 5, files: Array(0)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment