Skip to content

Tag: v8

How can Promise.resolve().then execute later?

Using native Javascript Promise: This is logged: Question: how is it possible for 2 to execute before 1? JS being event-driven, what is the event that is executing the callback given to then when the original caller has already left that execution tree? Is the engine doing some kind of behind-the-scene magic …

Is it more performant to mix types or to keep types?

I was wondering, with v8, when storing class attributes, is it more performant to use one variable with mixed types or one variable per type? Consider the following snippets (written in TypeScript for making the difference more clear): Afaik both should have advantages or defaults. Using one variable would ha…

Create big json object js

I am using Nodejs to Create a JSON file from a really large JSON object (1GB). In order to avoid memory problems, I’m using createWriteStream : After using Builder(custom function ) it will return a big object JSON. the final step is to create this file : but unfortunately, JSON.stringify cannot be used…

Object.entries() time complexity

Does anyone know the complexity of Object.entries() in Javascript? Based on this question I’d guess at maybe O(n) as well if it’s implemented by obtaining the keys and values as arrays then zipping them together? Answer (V8 developer here.) Short answer: yes, the complexity of Object.entries() is …

How does Promise Chaining work in memory?

Console Output: My main question is what is actually happening when the global execution context thread is finished and popped of the execution stack. How does JS/V8 know where this Promise Object is in memory if the Promise Object is not assigned to a variable within global execution context? How does it kno…

Relationship between event loop,libuv and v8 engine

I am learning through the architecture of Node.js. I have following questions. Is event loop a part of libuv or v8? Is event queue a part of event loop? are event queue generated by libuv or v8 engine or event loop itself? What is the connection between libuv and v8 engine? If event loop is single threaded, d…