Skip to content
Advertisement

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 here? Answer JavaScript maintains something called a callstack.

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 have the problem that the JS engine might make assumptions on

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 with such heavy Object JSON.stringify throws RangeError:

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 O(n) in most cases. For large objects (thousands of properties), it is O(n

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 know where to update the promise value and

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, does libuv come

Are arrow functions faster (more performant, lighter) than ordinary standalone function declaration in v8?

I am asking this question because I and my colleague have a dispute on coding style because he prefers arrows function declaration: And I prefer old-style standalone function declaration: My point is that code in old-style more readable and you can more clearly distinguish function and variable declarations. His point is that code with arrow functions just run faster. Do

How to Disable V8’s Optimizing Compiler

I’m writing a constant-time string comparison function (for node.js) and would like to disable V8’s optimizing compiler for this single function; using command-line flags are out of the question. I know that using a with{} (or try/catch) block will disable the optimizing compiler now, but I’m afraid this “feature” (bug) will be fixed in future versions. Is there an immutable

Advertisement