JS Spec debunking for toPrimitive on an object

Have tinkered with JavaScript majorly | I like to solve problems on Stack Overflow, write blog articles, create a side project or do something creative.
Search for a command to run...

Have tinkered with JavaScript majorly | I like to solve problems on Stack Overflow, write blog articles, create a side project or do something creative.
No comments yet. Be the first to comment.
Introduction Alright, alright, alright !!! I have officially completed three years at Hashnode now. If you have been following my blog for a while, I have this ritual of documenting what all went in the past year at my job. My general process for do...

Introduction Well here we are reflecting on my time at Hashnode the previous year. I have officially completed two years at Hashnode and as a part of ongoing ritual where I document the experience, here is another one.And also, in first quarter of 20...

Introduction One of the things when using the NextJS ecosystem that hasn't yet clicked for me is their Script component. https://nextjs.org/docs/pages/building-your-application/optimizing/scripts I have been running some experiments on how I can le...

Introduction This article will touch upon scenarios that I have encountered while working at Hashnode where some code reviews helped us prevent future rework on the same issue by having a broader perspective. Code Review 0 The Problem Sometime back,...

Introduction You're scrolling through Twitter (I still like calling it that) or Medium and you get a nice view of the sidebar as it snaps to the bottom or top of the page if you try to scroll beyond its boundaries. We will re-create the same experie...

Let's say we have an object by the variable name of obj and ToPrimitive abstract method has been called on it implicitly. This implicit call happens when you do a comparison like this - obj == 5 || false == obj etc.
Basically when one of the operands in a == comparison is a primitive and other one is an object.
For our case let's say we have this comparison - [] == 9.
The following is an attempt to clarify the working of toPrimitive as per spec :-
typeof [] is object or not which it is in our case.toPrimitive has been explicitly defined or not on the concerned object. Since it hasn't been for [], then exoticToPrim will be undefined.OrdinaryToPrimitive([],number) will be invoked for default hint.["valueOf","toString"].[].valueOf() = [] but [].toString() is "" which being
a primitive will be chosen."" == 9.I am no expert in specs debunking but I think this is what is happening. Feel free to comment and correct me if there is any wrong conclusion derived here.