Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Example of Logical OR assignment operator in es12

// In the example, the ||= will check if the songsCount is false (0).
// If false, then the right value will be assigned to the left variable.
let myPlaylist = {songsCount: 0, songs:[]};
myPlaylist.songsCount ||= 100;
console.log(myPlaylist); // This will print: {songsCount: 100, songs: Array(0)}
Source by softhunt.net #
 
PREVIOUS NEXT
Tagged: #Example #Logical #OR #assignment #operator
ADD COMMENT
Topic
Name
2+6 =