Questions tagged [v8]
V8 is Google's open source JavaScript engine.
3,026
questions
506
votes
10
answers
485k
views
What is Node.js? [closed]
I don't fully get what Node.js is all about. Maybe it's because I am mainly a web based business application developer. What is it and what is the use of it?
My understanding so far is that:
The ...
314
votes
7
answers
443k
views
How do I determine the correct "max-old-space-size" for Node.js?
I'm having some trouble to understand how Node.js acts based on the parameter max-old-space-size.
In my case, for example, I'm running two t2.small AWS instances (2GB of RAM).
Not sure why, but I did ...
190
votes
6
answers
129k
views
When to use next() and return next() in Node.js
Scenario: Consider the following is the part of code from a node web app.
app.get('/users/:id?', function(req, res, next){
var id = req.params.id;
if (id) {
// do something
} else ...
175
votes
6
answers
61k
views
What do the return values of node.js process.memoryUsage() stand for?
From the official documentation (source):
process.memoryUsage()
Returns an object describing the memory usage of the Node process
measured in bytes.
var util = require('util');
console.log(...
172
votes
4
answers
15k
views
Why is <= slower than < using this code snippet in V8?
I am reading the slides Breaking the Javascript Speed Limit with V8, and there is an example like the code below. I cannot figure out why <= is slower than < in this case, can anybody explain ...
169
votes
4
answers
13k
views
How does Bluebird's util.toFastProperties function make an object's properties "fast"?
In Bluebird's util.js file, it has the following function:
function toFastProperties(obj) {
/*jshint -W027*/
function f() {}
f.prototype = obj;
ASSERT("%HasFastProperties", true, obj);...
166
votes
2
answers
45k
views
ECMAScript 6 features available in Node.js 0.12
A new stable release of Node.js (0.12) has landed recently with an upgraded Google's v8 JavaScript engine, v3.28.73.
What ECMAScript 6 features are currently present in Node.js, without using the --...
162
votes
13
answers
100k
views
How to check which version of v8 is installed with my NodeJS?
How is V8 installed along with NodeJs? What version is my current V8 engine?
148
votes
5
answers
84k
views
Dumping whole array: console.log and console.dir output "... NUM more items]"
I am trying to log a long array so I can copy it quickly in my terminal. However, if I try and log the array it looks like:
['item',
'item',
>>more items<<<
... 399 more items ]
...
140
votes
14
answers
135k
views
Executing JavaScript without a browser?
I am looking into Javascript programming without a browser. I want to run scripts from the Linux or Mac OS X command line, much like we run any other scripting language (ruby, php, perl, python...)
$ ...
132
votes
10
answers
84k
views
Running V8 Javascript Engine Standalone
I want to run a Javascript console on top of V8. How do I do this?
131
votes
6
answers
72k
views
v8 JavaScript performance implications of const, let, and var?
Regardless of functional differences, does using the new keywords 'let' and 'const' have any generalized or specific impact on performance relative to 'var'?
After running the program:
function ...
127
votes
15
answers
189k
views
How to get a microtime in Node.js?
How can I get the most accurate time stamp in Node.js?
ps My version of Node.js is 0.8.X and the node-microtime extension doesn't work for me (crash on install)
122
votes
1
answer
12k
views
Why is Math.pow() (sometimes) not equal to ** in JavaScript?
I've just discovered the ECMAScript 7 feature a**b as an alternative for Math.pow(a,b) (MDN Reference) and came across a discussion in that post, in which they apparently behave differently. I've ...
113
votes
4
answers
50k
views
What is the performance of Objects/Arrays in JavaScript? (specifically for Google V8)
Performance associated with Arrays and Objects in JavaScript (especially Google V8) would be very interesting to document. I find no comprehensive article on this topic anywhere on the Internet.
I ...
110
votes
4
answers
8k
views
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 ...
105
votes
8
answers
35k
views
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 ...
100
votes
3
answers
82k
views
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 ...
99
votes
5
answers
47k
views
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 ...
84
votes
3
answers
19k
views
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?
83
votes
2
answers
23k
views
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 ...
79
votes
5
answers
42k
views
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)
78
votes
10
answers
89k
views
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 ...
76
votes
3
answers
24k
views
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?
75
votes
2
answers
3k
views
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 ...
71
votes
15
answers
170k
views
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 ...
70
votes
11
answers
42k
views
`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 ...
70
votes
5
answers
40k
views
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 ...
69
votes
1
answer
3k
views
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 ...
66
votes
2
answers
32k
views
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 ...
64
votes
3
answers
7k
views
What makes this function run much slower?
I've been trying to make an experiment to see if the local variables in functions are stored on a stack.
So I wrote a little performance test
function test(fn, times){
var i = times;
var t = ...
63
votes
6
answers
256k
views
Node.js: for each … in not working
I wanted to use for each ... in with Node.js (v0.4.11).
I use it like this:
var conf = {
index: {
path: {
first: "index.html",
pattern: "index/{num}.html"
},
...
62
votes
2
answers
4k
views
Why is the execution time of this function call changing?
Preface
This issue seems to only affect Chrome/V8, and may not be reproducible in Firefox or other browsers. In summary, the execution time of a function callback increases by an order of magnitude or ...
62
votes
2
answers
22k
views
How to run user-submitted scripts securely in a node.js sandbox?
What are the options for running (possibly malicious) user-submitted scripts in node.js, securely? I.e. in an environment that prevents code from accessing sensitive data and APIs?
vm....
61
votes
6
answers
158k
views
How can I check if a JSON is empty in NodeJS?
I have a function that checks to see whether or not a request has any queries, and does different actions based off that. Currently, I have if(query) do this else something else. However, it seems ...
60
votes
13
answers
48k
views
Why doesn't Node.js have a native DOM?
When I discovered that Node.js was built using the V8 JavaScript engine, I thought:
Great, web scraping will be easier as the page
will be rendered like in the browser, with a
"native" ...
60
votes
1
answer
2k
views
Is it possible to get stack traces across async/await boundaries using --harmony_async_await in Node 7?
We're experimenting with using --harmony_async_await in Node 7, and compared to transpiling with babel for async/await are missing the ability to have long stack traces (http://bluebirdjs.com/docs/api/...
59
votes
8
answers
45k
views
How do I escape a string for a shell command in node?
In nodejs, the only way to execute external commands is via sys.exec(cmd). I'd like to call an external command and give it data via stdin. In nodejs there does yet not appear to be a way to open a ...
56
votes
2
answers
18k
views
What exactly is the difference between v8::Isolate and v8::Context?
What is the difference/connection between these objects in V8? Does a context "belong" to an Isolate or vice versa?
I know that a single Isolate may only be accessed by one thread at a time (and that'...
54
votes
3
answers
12k
views
Do common JavaScript implementations use string interning?
Do common JavaScript engines, such as V8 and WebKit's JavaScriptCore, use string interning for JavaScript strings? Or do they actually keep multiple instances of identical strings in memory?
53
votes
2
answers
1k
views
Different results using the same maths in different browsers
Edit: since chrome has updated the browser - this question is some what redundant as they have fixed an internal bug which means this problem no longer occurs.
I have an animation of a circle ...
52
votes
3
answers
38k
views
What's the time complexity of array.splice() in Google Chrome?
If I remove one element from an array using splice() like so:
arr.splice(i, 1);
Will this be O(n) in the worst case because it shifts all the elements after i? Or is it constant time, with some ...
51
votes
2
answers
2k
views
slow function call in V8 when using the same key for the functions in different objects
Maybe not because the call is slow, but rather the lookup is; I'm not sure, but here is an example:
var foo = {};
foo.fn = function() {};
var bar = {};
bar.fn = function() {};
console.time('t');
...
48
votes
5
answers
24k
views
Android utilize V8 without WebView
I'm exercising executing javascript from Java. Rhino works very well for this on desktop, but has to fall back to (slow) interpreted mode on Android (due to dalvik being unable to execute the Java ...
47
votes
5
answers
46k
views
What's the maximum size of a Node.js Buffer
I got a fatal error reading a file that was too big to fit in a buffer.
FATAL ERROR: v8::Object::SetIndexedPropertiesToExternalArrayData() length exceeds max acceptable value
Or,
RangeError: "...
46
votes
1
answer
9k
views
How to read nodejs internal profiler tick-processor output
I'm interested in profiling my Node.js application.
I've started it with --prof flag, and obtained a v8.log file.
I've taken the windows-tick-processor and obtained a supposedly human readable ...
45
votes
5
answers
54k
views
How to debug node js app with breakpoints and everything?
I've installed node-inspector just to find out that it doesn't support breakpoints :| What's the point in it at all, bearing in mind that on big part node code is asynchronous and you simply cannot ...
42
votes
5
answers
25k
views
how to know which javascript version in my NODEJS?
I want to know which javascript version is my NodeJS is supporting ?
41
votes
3
answers
13k
views
Math.random() returns value greater than one?
While playing around with random numbers in JavaScript I discovered a surprising bug, presumably in the V8 JavaScript engine in Google Chrome. Consider:
// Generate a random number [1,5].
var rand5 =...
41
votes
4
answers
24k
views
Embed a JavaScript engine in an iOS application
I wonder if anyone has successfully ported a javascript engine/interpreter to iOS. I'm writing an iPhone game that I would like to use Javascript as the high-level scripting language (AI, gameplay, ...