Giter Club home page Giter Club logo

Comments (3)

anonyco avatar anonyco commented on May 27, 2024

Honestly, there is zero advantage to using let over var if one is using the variable properly because it only changes the scope. Using it properly means explicitly setting objects to null after they are used in circumstances where a timer is used in the same scope to the effect of consoling the browser with, "It's okay, this object is gone and will not be 'eval'ed anymore, so it can truely be freed." On the other hand, const can be used dangerously to prevent yourself from force GC-ing a variable. Observe:

const k = new Array(1024 * 1024 * 16);
for (let i=1024 * 1024 * 16; i; i--) k[i] = 0.1 - i; 
setTimeout(function(){
    // k has not yet been released from memory be it may still be yet used
}, 100, "e", "k", "a", "l", "v", "2");

As seen below:

const k = new Array(1024 * 1024 * 16);
for (let i=1024 * 1024 * 16; i; i--) k[i] = 0.1 - i; 
setTimeout(function(e, k, a, l, v, _2){
  window[e + v + a + l + _2]( "console.log(typeof " + k + ");" );
},  100, "e", "k", "a", "l", "v", "2");
setTimeout(function(e, k, a, l, v, _2){
  window[e + v + a + l + _2] =  window[e + v + a + l];
}, 20,  "e", "k", "a", "l", "v", "2");

Therefore, one must degrade themself to a self inflicted insanity of the human person which transgresses all human rights and violates all dignities endowed within the nature of man and javascript.

var k = new Array(1024 * 1024 * 16);
for (let i=1024 * 1024 * 16; i; i--) k[i] = 0.1 - i; 
setTimeout(function(e, k, a, l, v, _2){
  window[e + v + a + l + _2]( "console.log(typeof " + k + ");" );
},  100, "e", "k", "a", "l", "v", "2");
setTimeout(function(e, k, a, l, v, _2){
  window[e + v + a + l + _2] =  window[e + v + a + l];
}, 20,  "e", "k", "a", "l", "v", "2");
k = null; // necessary insanity thrust upon us by the common enemy living and walking amongst: OOP

from array-explorer.

itaditya avatar itaditya commented on May 27, 2024

@anonyco I'll know I mastered JavaScript when I'll understand your comment

from array-explorer.

sdras avatar sdras commented on May 27, 2024

IIRC (It's been a while since I made this), I used let because some of the methods mutate and so const wouldn't be permitted and I felt it was better to keep things consistent. I could have just let it be var I suppose. But that was the reasoning behind it. Open to more discussion about it.

from array-explorer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.