środa, 17 lutego 2016

ES6: Const or let or var?

ES6 / Es2015 introduces a lot of new extensions to the JavaScript world. One of these extensions are two new keywords used to variable declarations. So now in addition to the old var keyworld we have got let and const that allows us to declare a variable with a block scope. Oh great it may seem, we have so much choice, but the choice becomes problematic when it comes to writing code …

Suddenly you start writing code, you need to declare a variable and … there are questions like: when I use const, and when let, can I still use the var? These types of questions began to appear also in my team when we started to write in Node.js with ES6. It was important for us because we want in a team cohesive approach to the declaration, and because each member had a little different view of this, we had to discuss it …

First, we got acquainted closer with the let and const. about which many people have already written nice articles. I pasted below some interesting links to this topics.

https://davidwalsh.name/for-and-against-let
David Walsh Blog. For and against let Examining JavaScript ES6’s new ‘let’ keyword block for scoping, and conditions where it should or should not be used.
http://blog.getify.com/constantly-confusing-const/
Tearing down the confusions around the ES6 ‘const’ keyword
https://ponyfoo.com/articles/es6-let-const-and-temporal-dead-zone-in-depth
Pony Foo. Let ES6, Const and the “Temporal Dead Zone” (TDZ) in Depth This is yet another edition of ES6 in Depth. First time here? Welcome! So far in the covered destructuring, template literals,> arrow functions, the spread operator and rest …
and the last https://hacks.mozilla.org/2015/07/es6-in-depth-let-and-const/

Discussions on how to declare variable led my team to a discussion at the workshop within the company. Effect of such a summary here…

Steps to follow when declaring variable:

  1. If the variable is used throughout the function, use const or if a variable need reference rassigned , use var
  2. If you need a variable with block sopce (for example, in if condition), use const, if variable need to be assigned to a another object, use let
  3. use let with for (;;) loops.
As you can see we we initially start with const, becouse thanks to this we secure ourself from accidently reasigned veriable.You need to remember that With const you only receive unchenged reference to object but you can change objects properties. Objects declared with const are not immutable unless you use Object.freeze() (of course with nested object you shoul use Object.frezee() with recursion).

Quick summary

Is it realy worth it to follow some trends, fashion, not understanding why you should use this approach over another, or maybe it just because it looks prettier in the code? Why I should not use var if I know that my variable which I declared on top of the function will be used all over the function body…
My small advice, learn/read about new stuff to get better understanding and do whats best fit to you and your team and stick to those choices…

3 komentarze:

  1. Investment plansPROMO PACKAGE ?? BASIC Invest $70 earn $600 Invest $100 earn $1000  Invest $200 earn $2,000  Invest $300 earn $3,500  Invest $400 earn $4,500  Invest $500 earn $6,000 
    ?? PRO  Invest $1,000 earn $15,000  Invest $2,000 earn $25,000  Invest $3,000 earn $35,000  Invest $4,000 earn $45,000  Invest $5,000 earn $60,000  Invest $10,000 earn $100,000. 
    ?? PREMIUM  1BTC earn 5BTC  2BTC earn 10BTC  3BTC earn 16BTC  4BTC earn 22BTC  5BTC earn 30BTC. 
    ALL RETURNS ARE SCHEDULE, FOR 12 HOURS, UPON CONFIRMATION OF PAYMENTS.
    MODE OF PAYMENT. Any, Suitable For Investors, But Terms and Conditions Apply.
    ??HURRY NOW!!! Refer a Friend or Family member to invest same time, and Receive an instant $50 Reward. 
    To set up an INVESTMENT PLAN, Contact Admin: totalinvestmentcompany@gmail.com
    WhatsApp: +1(929)390-8581
    https://www.facebook.com/pg/Total-Investment-221964325813140/about/
    View more on YouTube: https://www.youtube.com/channel/UC3KWT9dTpFLi0S0vJTWuCJg

    OdpowiedzUsuń
  2. Are you interested in any kinds of hacking services?
    Feel free to contact TECHNECHHACKS.

    For years now we’ve helped so many organizations and companies in hacking services.
    TECHNECHHACKS is a team of certified hackers that has their own specialty and they are five star rated hackers.

    We give out jobs to hackers (gurus only) to those willing to work, with or without a degree, to speed up the availability of time given to jobs!!

    Thus an online binary decoding exam will be set for those who needs employment under the teams establishment.


    we deal with the total functioning of sites like,


    • SOCIAL MEDIA (Facebook, Twitter, Instagram, Snapchat, google hangout etc.)

    • SCHOOL GRADES

    • IOS/OS

    • CREDIT SCORES

    • BANK ACCOUNTS

    • SPOUSES PHONE

    Our special agents are five star rated agents that specializes in the following, and will specially be assigned to you for a special job well DONE.

    • WESTERN UNION TRANSFER

    • CREDIT CARDS INSTALLATION

    • MONEY FLIPPING

    • CRIMINAL RECORDS

    • BTC RECOVERY

    • BTC MINING

    • BTC INVESTMENT

    Thus bewere of scammers because most persons are been scammed and they ended up getting all solutions to their cyber bullies and attacks by US.

    I am Jason williams one of the leading hack agent.

    PURPOSE IS TO GET YOUR JOBS DONE AT EXACTLY NEEDED TIME REQUESTED!!!



    And our WORK SUCCESS IS 100%!!!



    We’re always available for you when you need help.

    Contact or write us on:

    Technechhacks@gmail.com

    SIGNED....!

    Jason. W

    Technechhacks
    2020©️All Right Reserved












    OdpowiedzUsuń
  3. Are you interested in any kinds of hacking services?
    Feel free to contact TECHNECHHACKS.

    For years now we’ve helped so many organizations and companies in hacking services.
    TECHNECHHACKS is a team of certified hackers that has their own specialty and they are five star rated hackers.

    We give out jobs to hackers (gurus only) to those willing to work, with or without a degree, to speed up the availability of time given to jobs!!

    Thus an online binary decoding exam will be set for those who needs employment under the teams establishment.


    we deal with the total functioning of sites like,


    • SOCIAL MEDIA (Facebook, Twitter, Instagram, Snapchat, google hangout etc.)

    • SCHOOL GRADES

    • IOS/OS

    • CREDIT SCORES

    • BANK ACCOUNTS

    • SPOUSES PHONE

    Our special agents are five star rated agents that specializes in the following, and will specially be assigned to you for a special job well DONE.

    • WESTERN UNION TRANSFER

    • CREDIT CARDS INSTALLATION

    • MONEY FLIPPING

    • CRIMINAL RECORDS

    • BTC RECOVERY

    • BTC MINING

    • BTC INVESTMENT

    Thus bewere of scammers because most persons are been scammed and they ended up getting all solutions to their cyber bullies and attacks by US.

    I am Jason williams one of the leading hack agent.

    PURPOSE IS TO GET YOUR JOBS DONE AT EXACTLY NEEDED TIME REQUESTED!!!



    And our WORK SUCCESS IS 100%!!!



    We’re always available for you when you need help.

    Contact or write us on:

    Technechhacks@gmail.com

    SIGNED....!

    Jason. W

    Technechhacks
    2020©️All Right Reserved

    OdpowiedzUsuń