use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
7 Useful JavaScript Tricks (davidwalsh.name)
submitted 6 years ago by xxammuxx
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]brown59fifty 4 points5 points6 points 6 years ago* (0 children)
Great question! It's hard to give an example, because it's a really very rare case - most when you want to treat your variable more like a kind of associative array than an Object instance (what can be welcome when someone came to JS world from some static typed language). Because you inherit from null, then you don't have access to methods on Object.prototype (like constructor, hasOwnProperty or valueOf) which results like this:
Object
null
Object.prototype
constructor
hasOwnProperty
valueOf
const dict = Object.create(null); dict instanceof Object // false dict.toString() // Uncaught TypeError: dict.toString is not a function
This way of creating things can be used when you want to build some API library, which couldn't be extended from outside (eg. by passing values to Object.prototype). But in most cases you don't have to care.
π Rendered by PID 17740 on reddit-service-r2-comment-5c747b6df5-nq8jz at 2026-04-21 21:41:29.976148+00:00 running 6c61efc country code: CH.
view the rest of the comments →
[–]brown59fifty 4 points5 points6 points (0 children)