loading

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.4550296935319009","path":"main.js","file":{"path":"main.js","content":{"asEncoding":{"base64":"Ly8gRGF0YSBkZWZpbml0aW9uCnZhciBwcmltZU51bWJlcnMgPSBbMiwzLDUsNywxMV07CgovLyBPcHRpb24gMSkgT2xkZXN0IHdheSAmIGxlYXN0IGVmZmljaWVudCwgYXNzaWducyBsZW5ndGggb24gZWFjaCBpdGVyYXRpb24gYW5kIGkgaG9pc3RlZCB0byB0aGUgdG9wCnZhciBsb29wU3RhcnRPcHQxID0gcGVyZm9ybWFuY2Uubm93KCk7CmZvciAodmFyIGkgPSAwOyBpIDwgcHJpbWVOdW1iZXJzLmxlbmd0aDsgaSsrKSB7CiAgY29uc29sZS5sb2cocHJpbWVOdW1iZXJzW2ldKTsKfQpjb25zb2xlLmxvZyggcGVyZm9ybWFuY2Uubm93KCkgLWxvb3BTdGFydE9wdDEgKyAnIG1zJykKCi8vIE9wdGlvbiAyKSBJbXByb3ZlZCBsb29wLCBhc3NpZ25zIGxlbmd0aCB0byB2YXJpYWJsZSAmIGRlZmluZXMgaSB0byBhdm9pZCBob2lzdGluZwp2YXIgZGF0YUxlbmd0aCA9IHByaW1lTnVtYmVycy5sZW5ndGgsIGk7Cgp2YXIgbG9vcFN0YXJ0T3B0MiA9IHBlcmZvcm1hbmNlLm5vdygpOwpmb3IgKGkgPSAwOyBpIDwgZGF0YUxlbmd0aDsgaSsrKSB7CiAgY29uc29sZS5sb2cocHJpbWVOdW1iZXJzW2ldKTsKfQpjb25zb2xlLmxvZyhwZXJmb3JtYW5jZS5ub3coKSAtIGxvb3BTdGFydE9wdDIgKyAnIG1zJykK"},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// Data definition
var primeNumbers = [2,3,5,7,11];

// Option 1) Oldest way & least efficient, assigns length on each iteration and i hoisted to the top
var loopStartOpt1 = performance.now();
for (var i = 0; i < primeNumbers.length; i++) {
  console.log(primeNumbers[i]);
}
console.log( performance.now() -loopStartOpt1 + ' ms')

// Option 2) Improved loop, assigns length to variable & defines i to avoid hoisting
var dataLength = primeNumbers.length, i;

var loopStartOpt2 = performance.now();
for (i = 0; i < dataLength; i++) {
  console.log(primeNumbers[i]);
}
console.log(performance.now() - loopStartOpt2 + ' ms')
Native Browser JavaScript