This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Generate a random HEX color | |
| randomColor = () => `#${Math.random().toString(16).slice(2, 8).padStart(6, '0')}`; | |
| // Or | |
| const randomColor = () => `#${(~~(Math.random()*(1<<24))).toString(16)}`; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Swap the values of 2 variables | |
| let a = 1; | |
| let b = 2; | |
| [a, b] = [b, a]; | |
| // Result: | |
| // a = 2 | |
| // b = 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| / Get the text that the user has selected | |
| const getSelectedText = () => window.getSelection().toString(); | |
| getSelectedText(); |
OlderNewer