Questions tagged [v8]

V8 is Google's open source JavaScript engine.

About V8

V8 is Google's Javascript engine that is used in Google Chrome (). It is written in C++ (), and is open source, which can be checked out by following the instructions on the v8 wiki.

V8 can run standalone, or can be embedded into C++ applications.

Documentation on V8 can be found on its wiki pages.

There are a number of flags that can be passed to V8 to expose its internals. For instance, --trace-deopt gets V8 to log code deoptimizations, and --expose-gc allows scripts to manually invoke a garbage collection. The full list of flags can be found by reading the source.

Links:

Tag Usage

Use this tag to ask questions about:

  • Usage of the V8 API
  • Performance and profiling with V8
  • How V8 works
2955 questions
110
votes
4 answers

Why does the value of typeof null change inside a loop?

Executing this snippet in the Chrome console: function foo() { return typeof null === 'undefined'; } for(var i = 0; i < 1000; i++) console.log(foo()); should print 1000 times false, but on some machines will print false for a number of…
Agos
  • 18,542
  • 11
  • 56
  • 70
98
votes
5 answers

What version of Javascript is supported in node.js

I'm getting started with Node.js and I'm having a hard time figuring out what version of JavaScript is supported by node which makes it difficult figuring out what features I can use. Here's what I know. Node uses V8 V8 implements ECMAScript as…
emtrane
  • 1,049
  • 1
  • 8
  • 10
96
votes
3 answers

What are the differences between Long Term Support (LTS) and Stable versions of Node.js?

Originally asked: What is the difference between Node.js 4.x branch with LTS (Long Term Support) and the 5.x branch (listed as Stable)? But this is equally relevant to understanding the difference between 6.x and 7.x and, in the future, 8.x and…
AndrewMcLagan
  • 13,459
  • 23
  • 91
  • 158
95
votes
8 answers

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: const sum = (a, b) => a + b; And I prefer old-style standalone function declaration: function sum(a, b) { return…
Alexander Myshov
  • 2,881
  • 2
  • 20
  • 31
84
votes
3 answers

Nodejs: What does `process.binding` mean?

I've seen process.binding('...') many times while researching through the node.js source code on github. Can anybody explain me what this function does?
laconbass
  • 17,080
  • 8
  • 46
  • 54
84
votes
2 answers

Why is bind slower than a closure?

A previous poster asked Function.bind vs Closure in Javascript : how to choose? and received this answer in part, which seems to indicate bind should be faster than a closure: Scope traversal means, when you are reaching to grab a value …
Paul
  • 26,170
  • 12
  • 85
  • 119
78
votes
10 answers

Rails: Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)

My website has been broken since Dreamhost upgraded their servers a couple of weeks ago. I have been tearing my hair out trying to get it fixed and made some progress but am stuck on what is hopefully the final issue. I'm using Rails 3.1.1 on Ruby…
Rich
  • 2,164
  • 1
  • 25
  • 39
76
votes
5 answers

es6 Map and Set complexity, v8 implementation

Is it a fair assumption that in v8 implementation retrieval / lookup is O(1)? (I know that the standard doesn't guarantee that)
Uri
  • 25,622
  • 10
  • 45
  • 72
75
votes
2 answers

Understanding JavaScript heap growth and GC pattern

In a vain attempt to write perfect javascript I am tackling the issue of the Javascript heap. I have got it down to the lowest level I can but I have run out of options, and don't understand what is going on (well my guess is rAF overhead, but…
Blindman67
  • 51,134
  • 11
  • 73
  • 136
73
votes
3 answers

What is the relationship between Node.js and V8?

I've been thinking about this question for a while and can't seem to find the answer. What is the relationship between Node.js and V8? and Can Node.js work without V8?
Chanlito
  • 2,322
  • 2
  • 17
  • 27
71
votes
5 answers

Javascript Engines Advantages

I am confused about JavaScript engines right now. I know that V8 was a big deal because it compiled JavaScript to native code. Then I started reading about Mozilla SpiderMonkey, which from what I understand is written in C and can compile…
Jan
  • 719
  • 1
  • 6
  • 3
70
votes
11 answers

`gem install therubyracer` fails on Mac OS X Lion

I would appreciate some help in getting gem install therubyracer to work. Here is the error: $ gem install therubyracer Building native extensions. This could take a while... ERROR: Error installing therubyracer: ERROR: Failed to build gem…
David J.
  • 31,569
  • 22
  • 122
  • 174
69
votes
15 answers

How to efficiently check if variable is Array or Object (in NodeJS & V8)?

Is there any way to efficiently check if the variable is Object or Array, in NodeJS & V8? I'm writing a Model for MongoDB and NodeJS, and to traverse the object tree I need to know if the object is simple (Number, String, ...) or composite (Hash,…
Alex Craft
  • 13,598
  • 11
  • 69
  • 133
69
votes
1 answer

How to read audio data from a 'MediaStream' object in a C++ addon

After sweating blood and tears I've finally managed to set up a Node C++ addon and shove a web-platform standard MediaStream object into one of its C++ methods for good. For compatibility across different V8 and Node.js versions, I'm using Native…
John Weisz
  • 30,137
  • 13
  • 89
  • 132
66
votes
2 answers

Accessing line number in V8 JavaScript (Chrome & Node.js)

JavaScript developers who have spent time in languages like C often miss the ability to use certain types of introspection, like logging line numbers, and what method the current method was invoked from. Well if you're using V8 (Chrome, Node.js) you…
james_womack
  • 10,028
  • 6
  • 55
  • 74