برنامه نویسی

متغیرها – انجمن DEV

پیشنهاد ویژه

[button color="primary" size="big" link="https://nabfollower.com/buy-real-follower/" icon="" target="true" follow="false"]خرید فالوور واقعی[/button][button color="primary" size="big" link="https://nabfollower.com/buy-instagram-like/" icon="" target="true" follow="false"]خرید لایک اینستاگرام[/button][button color="primary" size="big" link="https://nabfollower.com/buy-instagram-views/" icon="" target="true" follow="false"]خرید ویو اینستاگرام[/button][button color="primary" size="big" link="https://nabfollower.com/" icon="" target="true" follow="false"]خرید فالوور اینستاگرام[/button]

  • متغیرها در جاوا اسکریپت محفظه هایی برای ذخیره مقادیر داده ها هستند.
  • آنها با استفاده از var، let، یا const کلید واژه ها.
  • متغیرهای اعلام شده با var دارای دامنه تابع یا دامنه جهانی هستند، در حالی که آنهایی که با آن اعلام شده اند let یا const دارای محدوده بلوک
  • استفاده از آن توصیه می شود let یا const برای اعلامیه های متغیر برای جلوگیری از مسائل مربوط به محدوده و بالا بردن.
// Variable declaration with var (function-scoped)
var firstName = "John";
console.log(firstName); // Output: John

// Variable declaration with let (block-scoped)
let lastName = "Doe";
console.log(lastName); // Output: Doe

// Variable declaration with const (block-scoped constant)
const age = 30;
console.log(age); // Output: 30
وارد حالت تمام صفحه شوید

از حالت تمام صفحه خارج شوید

نوشته های مشابه

دیدگاهتان را بنویسید

نشانی ایمیل شما منتشر نخواهد شد. بخش‌های موردنیاز علامت‌گذاری شده‌اند *

دکمه بازگشت به بالا