Ana sayfa Genel Javascript – ES6 ile beraber gelen Let ve Const Nedir ?

Javascript – ES6 ile beraber gelen Let ve Const Nedir ?


Herkese Merhaba,

Bildiğiniz üzere Javascript son zamanlarda iyice popüleritesini artıran ve sürekli yeni standartlarla güncellenen bir programlama dili. Bu yazımızda ES6 ile beraber gelen ve değişken tanımlamak için kullanılan let ve const anahtar kelimelerini ve Javascriptin ilk çıktığı zamanlardan beri kullanılan var anahtar kelimesiyle olan farklıları göreceğiz.

Şimdi ilk olarak Javascriptteki scope’un(kapsamın) ne anlama geldiğini anlamaya çalışalım.

Scope(Kapsam) Kavramı

Scope veya kapsam bir değişkenin program devam ederken nerelerde var olduğunu anlatmak için kullanılan bir kavramdır ve Javascriptte 3 farklı scope bulunmaktadır.

Global Scope

Global Scopeta tanımlanan bir değişkene her yerden ulaşılabilir.

Function Scope

Fonksiyonların içinde tanımlanan değişkenler sadece fonksiyonun içinde var olur ve yalnızca fonksiyon içinden erişilebilirler.

Block Scope

Block Scope ise if,while benzeri blokları simgeler. İşte burada var,let ve const’un farklarına bakmaya başlayabiliriz.

var Anahtar Kelimesi

var anahtar kelimesiyle tanımlanan bir değişken aynı isimle birden fazla kez tanımlanabilir ve block scopeta tanımlanmışsa bile global scopeta var olmaya devam eder.


var ile tanımlanan değişkenlerin tekrar tekrar aynı isimle tanımlanmaları kaynak kod uzadıkça isim karışmasına ve düzensizliğe sebep olabilir. Bir de şu örneğe bakalım.

Programlarımızda bir değişkenin sadece o anki blokta var olmasını istediğimizde burada yine var kullanımının sıkıntısını çekiyoruz.

let Anahtar Kelimesi

let anahtar kelimesiyle tanımlanan değişkenler sadece aynı isimle bir defa tanımlanabilir ve Block Scopeta tanımlandığında sadece o blokta var olur. Burada let anahtar kelimesinin var ile farkını görebiliyoruz.


const Anahtar Kelimesi

Javascriptte const ile tanımlanan bir değişken sadece bir defa tanımlanabilir ve programın ileriki kısımlarda direk olarak bu değişkene değer ataması yapılamaz.

Ancak Javascriptte const anahtar kelimesiyle tanımlanan değişkenlerin değeri dolaylı yollardan (direk atama yapılmadan) değiştirilebilir.

Hangisini Kullanalım ?

Aslında yazılımcılığın doğasında kararlarda özgür olma vardır. Bir yazılımcı hangi yöntemi kullanmak isterse onu kullanır. Kesin yargılar ve “bunu kullanın” gibi söylemler yanlış olabilir. Ancak farkettiyseniz var anahtar kelimesinin 2 tane önemli dezavantajı bulunuyor. Bu dezavantajlar programlarımızda sıkıntı çıkarabileceğinden ihtiyacımıza göre sadece let veya const kullanarak Javascriptte geliştirme yapmaya devam edebiliriz.


  1. It is really a great and useful piece of info. I’m glad that you shared this helpful information with us. Please keep us up to date like this. Thanks for sharing.

  2. Do you mind if I quote a few of your articles as long as I provide credit and sources back to your blog?
    My blog site is in the exact same area of interest as yours and my
    visitors would really benefit from a lot of the information you present
    here. Please let me know if this okay with you. Many thanks!

  3. After research just a few of the weblog posts in your website now, and I truly like your way of blogging. I bookmarked it to my bookmark website record and might be checking again soon. Pls check out my website online as properly and let me know what you think.

  4. I loved as much as you will receive carried out right here. The sketch is tasteful, your authored material stylish. nonetheless, you command get bought an edginess over that you wish be delivering the following. unwell unquestionably come more formerly again as exactly the same nearly very often inside case you shield this increase.

  5. An impressive share, I simply given this onto a colleague who was doing somewhat evaluation on this. And he in reality purchased me breakfast as a result of I discovered it for him.. smile. So let me reword that: Thnx for the treat! However yeah Thnkx for spending the time to discuss this, I really feel strongly about it and love reading more on this topic. If possible, as you change into expertise, would you thoughts updating your weblog with extra particulars? It is highly useful for me. Big thumb up for this blog put up!

  6. Thanks for sharing superb informations. Your site is so cool. I am impressed by the details that you’ve on this site. It reveals how nicely you understand this subject. Bookmarked this web page, will come back for extra articles. You, my pal, ROCK! I found simply the information I already searched everywhere and simply couldn’t come across. What a great site.

  7. There are certainly numerous details like that to take into consideration. That could be a nice level to bring up. I supply the thoughts above as general inspiration but clearly there are questions just like the one you bring up where a very powerful thing will be working in honest good faith. I don?t know if best practices have emerged around things like that, however I am certain that your job is clearly recognized as a fair game. Both girls and boys feel the affect of just a moment’s pleasure, for the rest of their lives.

  8. What i don’t realize is in reality how you’re no longer really
    a lot more neatly-favored than you might be now. You’re so intelligent.
    You know thus considerably in the case of this matter, produced me personally imagine it from numerous various
    angles. Its like men and women are not involved unless it is one thing to do with Lady gaga!
    Your individual stuffs outstanding. All the time take
    care of it up!

  9. You are my intake, I possess few blogs and occasionally run out from brand :). “Follow your inclinations with due regard to the policeman round the corner.” by W. Somerset Maugham.

  10. A lot of the things you point out happens to be astonishingly precise and that makes me ponder why I had not looked at this in this light before. This piece really did switch the light on for me as far as this specific issue goes. Nevertheless at this time there is actually 1 position I am not too cozy with and whilst I try to reconcile that with the central idea of your point, let me observe just what all the rest of your readers have to point out.Well done.

  11. I have not checked in here for a while as I thought it was getting boring, but the last several posts are great quality so I guess I will add you back to my everyday bloglist. You deserve it my friend 🙂

  12. As I web site possessor I believe the content matter here is rattling magnificent , appreciate it for your hard work. You should keep it up forever! Good Luck.

  13. Admiring the time and energy you put into your website and in depth information you provide. It’s awesome to come across a blog every once in a while that isn’t the same unwanted rehashed material. Excellent read! I’ve saved your site and I’m adding your RSS feeds to my Google account.

  14. Everyone loves what you guys tend to be up too.
    This kind of clever work and coverage! Keep up the good
    works guys I’ve added you guys to blogroll.

  15. Good post however I was wanting to know if you could write a litte more on this topic? I’d be very grateful if you could elaborate a little bit more. Thank you!

  16. First of all I want to say terrific blog!
    I had a quick question that I’d like to ask if you do not mind.
    I was curious to know how you center yourself
    and clear your mind before writing. I’ve had a
    hard time clearing my mind in getting my thoughts out there.
    I truly do enjoy writing however it just seems like the
    first 10 to 15 minutes are generally wasted simply just
    trying to figure out how to begin. Any ideas or tips? Appreciate

  17. Thanks , I’ve just been looking for info about this topic for ages and yours is the best I have discovered so far. But, what about the conclusion? Are you sure about the source?

  18. Fantastic beat ! I wish to apprentice while you amend your website, how can i subscribe for a blog site? The account helped me a acceptable deal. I had been a little bit acquainted of this your broadcast provided bright clear concept

  19. It’s really a nice and useful piece of information. I’m glad that you shared this helpful information with us. Please keep us informed like this. Thank you for sharing.

  20. Hi, Neat post. There’s a problem together with your site in internet explorer, might test this… IE still is the market chief and a huge component to other people will omit your excellent writing due to this problem.

  21. Oh my goodness! an incredible article dude. Thanks Nonetheless I’m experiencing subject with ur rss . Don’t know why Unable to subscribe to it. Is there anyone getting an identical rss drawback? Anybody who knows kindly respond. Thnkx

  22. Do you mind if I quote a few of your posts as long as I provide credit and sources back to your blog? My blog is in the very same niche as yours and my users would definitely benefit from some of the information you provide here. Please let me know if this okay with you. Cheers!

  23. Hi! I know this is somewhat off-topic however I had to ask.

    Does managing a well-established blog such as yours require a lot
    of work? I’m brand new to running a blog but I do write in my
    journal on a daily basis. I’d like to start a blog so I will be able to share my
    experience and thoughts online. Please let me know if you
    have any kind of suggestions or tips for brand new
    aspiring blog owners. Appreciate it!

  24. An fascinating dialogue is value comment. I feel that you should write extra on this subject, it may not be a taboo subject however usually individuals are not enough to speak on such topics. To the next. Cheers

  25. When I originally commented I clicked the -Notify me when new comments are added- checkbox and now each time a comment is added I get four emails with the same comment. Is there any way you can remove me from that service? Thanks!

  26. Hi, Neat post. There is an issue together with your website in internet explorer, may check this… IE nonetheless is the market leader and a huge component to folks will pass over your magnificent writing because of this problem.

  27. I have been exploring for a bit for any high quality articles or weblog posts on this sort of space . Exploring in Yahoo I at last stumbled upon this site. Studying this information So i am happy to exhibit that I’ve an incredibly just right uncanny feeling I came upon just what I needed. I so much unquestionably will make certain to do not forget this web site and give it a glance on a constant basis.

  28. Hello there, There’s no doubt that your site might be having browser compatibility problems.
    Whenever I look at your web site in Safari, it looks fine but when opening in IE, it’s
    got some overlapping issues. I simply wanted to give you a quick
    heads up! Besides that, great site!

  29. Ellanse洢蓮絲(依戀詩)是一款荷蘭與英國共同研發的的新型真皮填充劑,是由30的25-50微米(µm)的聚己內酯(polycaprolactone, PCL)完美微型正圓晶球,以及70的PBS-生物降解材料(carboxymethylcellulose, CMC)製成的凝膠體,這些成分都是通過FDA(美國食品藥品監督管理局)和歐洲CE認證的安全成分,在人體內水分和二氧化碳作用下可以完全被分解吸收和排出的安全物質,對人體不會產生過敏反應,因此治療前不需經過敏檢測,在使用上幾乎不產生副作用。

  30. I’ve been browsing on-line more than three hours today, but I never discovered any attention-grabbing article like yours. It¦s beautiful value sufficient for me. In my view, if all website owners and bloggers made just right content as you did, the internet shall be much more helpful than ever before.

  31. Hiya! I know this is kinda off topic but I’d figured I’d ask. Would you be interested in exchanging links or maybe guest authoring a blog post or vice-versa? My blog discusses a lot of the same topics as yours and I believe we could greatly benefit from each other. If you are interested feel free to send me an e-mail. I look forward to hearing from you! Terrific blog by the way!

  32. I would like to thank you for the efforts you have put in writing this website. I am hoping the same high-grade web site post from you in the upcoming also. In fact your creative writing skills has inspired me to get my own site now. Really the blogging is spreading its wings fast. Your write up is a great example of it.

  33. I’ve been absent for some time, but now I remember why I used to love this web site. Thanks , I’ll try and check back more often. How frequently you update your web site?

  34. Wonderful post however I was wanting to know if you could write a litte more on this subject? I’d be very thankful if you could elaborate a little bit more. Cheers!

  35. After research a couple of of the blog posts in your web site now, and I truly like your manner of blogging. I bookmarked it to my bookmark website checklist and might be checking back soon. Pls take a look at my site as properly and let me know what you think.

  36. The other day, while I was at work, my sister stole my apple ipad and tested to see if it can survive a forty foot drop, just so she can be a youtube sensation. My apple ipad is now destroyed and she has 83 views. I know this is entirely off topic but I had to share it with someone!

  37. Hi, I do think this is an excellent blog. I stumbledupon it 😉 I may return once again since
    i have bookmarked it. Money and freedom is the best way to change,
    may you be rich and continue to help other people.

  38. Have you ever thought about including a little bit more than just your articles? I mean, what you say is valuable and everything. Nevertheless just imagine if you added some great pictures or video clips to give your posts more, “pop”! Your content is excellent but with pics and clips, this website could definitely be one of the best in its field. Fantastic blog!

  39. My spouse and i got very fortunate when John could round up his investigations while using the precious recommendations he grabbed from your web page. It’s not at all simplistic to simply always be making a gift of facts other folks have been making money from. Therefore we figure out we need the writer to be grateful to for that. The type of explanations you have made, the straightforward web site menu, the relationships you can help engender – it’s mostly fabulous, and it’s letting our son in addition to us consider that that subject matter is thrilling, and that is exceedingly vital. Many thanks for all!

  40. I think other website proprietors should take this website as an model, very clean and excellent user friendly style and design, as well as the content. You are an expert in this topic!

  41. Attractive portion of content. I just stumbled upon your website and in accession capital to say that I acquire in fact enjoyed account your blog posts. Anyway I’ll be subscribing for your augment or even I achievement you get admission to persistently fast.

  42. Thank you so much for giving everyone such a wonderful chance to read from this site. It is often very sweet and jam-packed with fun for me personally and my office acquaintances to search your website no less than three times in a week to read through the fresh things you have got. And of course, I am also certainly fascinated with all the unbelievable concepts you give. Certain two points on this page are unequivocally the simplest we have had.

  43. Thank you for sharing superb informations. Your web-site is so cool. I’m impressed by the details that you have on this web site. It reveals how nicely you perceive this subject. Bookmarked this web page, will come back for more articles. You, my friend, ROCK! I found just the information I already searched everywhere and simply could not come across. What an ideal website.


Lütfen yorumunuzu giriniz
Buraya isminizi giriniz