---
title: "Tony B (@octree) | Hashnode"
description: "Tony B (@octree) writes on Hashnode. Read their latest articles and follow their work."
url: "https://hashnode.com/@octree"
---

@octree

# Tony B

@octree · Joined January 2021

## Comments

[Although there are a lot of good uses for Singletons, this example is a little ironic. The use of a Module means there is only one instance of the Singleton constant, so the entire class is unnecessary. In rare cases where complex dependencies and versions create multiple instances of a module, your example wouldn't work anyway as there would be multiple instances. i.e. just use const Singleton = new Username() in your module and move on :)](https://hashnode.com/posts/singleton-pattern-in-javascript/608d4c86a3716542f363f123/comment/608d8459a3716542f363f46c)

Comment · Article · May 1, 2021 · [Singleton Pattern in Javascript](https://hashnode.com/posts/singleton-pattern-in-javascript/608d4c86a3716542f363f123)

[David Morais I don't think you are correct about your example being a closure - even according to MDN's explanation. "a function bundled together (enclosed) with references to its surrounding state" You took the bit about surrounding state, but ignored the bit about a function being bundled together/enclosed. Your example is just looking at global state - that isn't bundled, that is open to everyone to mess with. :) I would update it anyway for teaching purposes, as the rest of your article is excellent IMHO.](https://hashnode.com/posts/you-may-not-know-js/60762cecab0af52a0fead63a/comment/6076e52ca3407a32d7041761#reply-6076fa5aa3407a32d7041afb)

Reply · Article · Apr 14, 2021 · [You (may not) Know JS](https://hashnode.com/posts/you-may-not-know-js/60762cecab0af52a0fead63a)

[Nice article. If performance isn't a huge concern, you can also just do this. arr.sort((a,b) => !!b - !!a) In recent versions of JavaScript the array sort is stable so the order of equal elements from the compare remains unchanged](https://hashnode.com/posts/moving-zeros-code-challenge-javascript-data-structures-and-algorithms/5fbd4c20ec43af1ba609509c/comment/5ff61acce8e57e1374e6af23)

Comment · Article · Jan 6, 2021 · [Moving Zeros Code Challenge - JavaScript Data Structures and Algorithms](https://hashnode.com/posts/moving-zeros-code-challenge-javascript-data-structures-and-algorithms/5fbd4c20ec43af1ba609509c)
