Skip to content

Instantly share code, notes, and snippets.

View trevor-atlas's full-sized avatar
👾
Variety is the spice of life, or something

Trevor Atlas trevor-atlas

👾
Variety is the spice of life, or something
View GitHub Profile
🔥
┏🔥🔥
┃┃╱╲ in
┃╱🔥╲ this
╱ ╭╮ ╲ house
▔▏┗┛▕▔ we🔥🔥
╱▔▔🔥▔▔▔▔▔▔▔╲
🔥TEST IN PRODUCTION
╱ ┏┳┓╭🔥┏┳┓ ╲
▔▏ ┗┻┛┃┃ ┗┻┛🔥▕▔
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣠⣶⡾⠏⠉⠙⠳⢦⡀⠀⠀⠀⢠⠞⠉⠙⠲⡀⠀
⠀⠀⠀⣴⠿⠏⠀⠀⠀⠀⠀⠀⢳⡀⠀⡏⠀⠀⠀⠀⠀⢷
⠀⠀⢠⣟⣋⡀⢀⣀⣀⡀⠀⣀⡀⣧⠀⢸⠀Ship ⡇
⠀⠀⢸⣯⡭⠁⠸⣛⣟⠆⡴⣻⡲⣿⠀⣸⠀it! ⡇
⠀⠀⣟⣿⡭⠀⠀⠀⠀⠀⢱⠀⠀⣿⠀⢹⠀⠀⠀⠀⠀ ⡇
⠀⠀⠙⢿⣯⠄⠀⠀⠀⢀⡀⠀⠀⡿⠀⠀⡇⠀⠀⠀⠀⡼
⠀⠀⠀⠀⠹⣶⠆⠀⠀⠀⠀⠀⡴⠃⠀⠀⠘⠤⣄⣠⠞⠀
⠀⠀⠀⠀⠀⢸⣷⡦⢤⡤⢤⣞⣁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⢀⣤⣴⣿⣏⠁⠀⠀⠸⣏⢯⣷⣖⣦⡀⠀⠀⠀⠀⠀⠀
░░░░░░░░░░░░▄█▀█▀▀▀▀▀▀▀▀▄▄░░░░░░░░
░░░░░░░░░░▄██▀░█░░░░░░░░░░▀▀▄▄░░░░
░░░░░░░░░░███▀█▀█▄▄▄▄▄▄▄▒▒▒▄███░░░
░░░░░░░░▄██░░░░█░░░░░░░░▀▀▀▀▀▀█░░░
░░░░░░▄███░░░░░░█░░░░░░░░░░░░░░░░░
░░░░░█████▄░░░░░█░░░░░░░░░░░░░░░░░
░░░░████████▄▄░█░░░░A░NEW░░░░░░░░░
░░░████████████░░░░░RELEASE░░░░░░░
░░░▀██████████░░░░░░░░HAS░░░░░░░░░
░░░░██▒▀█▒▀█▀░░░░░░░░░░ARRIVED░░░░
▄▄▄▄▄▄▄▄▄
░▄███████▀▀▀▀▀▀███████▄
░▐████▀▒ Ship ▒▒▒▒▀██████▄
░███▀▒▒▒▒ it! ▒▒▒▒▒▀█████
░▐██▒▒▒▒▒▒ ~~~~ ▒▒▒▒▒▒████▌
░▐█▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▌
░░█▒▄▀▀▀▀▀▄▒▒▄▀▀▀▀▀▄▒▐███▌
░░░▐░░░▄▄░░▌▐░░░▄▄░░▌▐███▌
░▄▀▌░░░▀▀░░▌▐░░░▀▀░░▌▒▀▒█▌
░▌▒▀▄░░░░▄▀▒▒▀▄░░░▄▀▒▒▄▀▒▌
──────▄▌▐▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▌
───▄▄ █ █ Ship it! ~~~~~~~~~~~
███████▌█▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▌
▀(@)▀▀▀▀▀▀▀(@)(@)▀▀▀▀▀▀▀▀▀▀▀▀▀(@)▀
__---~~~~--__ __--~~~~---__
`\---~~~~~~~~\\ //~~~~~~~~---/'
\/~~~~~~~~~\|| ||/~~~~~~~~~\/
`\\ //'
`\\ //'
|| || Hey Doc!
______--~~~~~~~~~~~~~~~~~~--______
___ // _-~ ~-_ \\ ___
`\__)\/~ ~\/(__/'
_--`-___ ___-'--_

In JavaScript, undefined is nothing but a global variable name without a default value. Therefore, its primitive value is undefined. You can change the value of undefined:

const a = {};
a.b === undefined; // true because property b is not set
undefined = 42;
a.b === undefined; // false

Due to the mutability of undefined, it is generally a better idea to check for undefined-ness through typeof or void:

@trevor-atlas
trevor-atlas / is-symmetric-tree.js
Created December 12, 2018 02:57
Check a binary tree for symmetry
/**
* Definition for a binary tree node.
* function TreeNode(val) {
* this.val = val;
* this.left = this.right = null;
* }
*/
/**
* @param {TreeNode} root
* @return {boolean}
@trevor-atlas
trevor-atlas / is-valid-bst.js
Created December 12, 2018 02:38
Validate BST
/**
* Definition for a binary tree node.
* function TreeNode(val) {
* this.val = val;
* this.left = this.right = null;
* }
*/
/**
* @param {TreeNode} node
* @return {boolean}
@trevor-atlas
trevor-atlas / dates.java
Last active December 20, 2018 15:44
Useful Java date and time one liners and functions
// get the current year as an int, E.G: 2018
Calendar.getInstance().get(Calendar.YEAR);
/* get date as iso 8601 string
* public static Instant now()
* Obtains the current instant from the system clock.
* This will query the system UTC clock to obtain the current instant.
*
* public String toString()
* A string representation of this instant using ISO-8601 representation.