freeCodeCamp/guide/arabic/certifications/javascript-algorithms-and-d.../basic-javascript/local-scope-and-functions/index.md

18 lines
697 B
Markdown
Raw Normal View History

---
title: Local Scope and Functions
localeTitle: النطاق المحلي والوظائف
---
## النطاق المحلي والوظائف
النطاق المحلي يعني أن المتغير متاح داخل منطقة معينة. في حالة هذا التمرين ، لا يتوفر `myVar` إلا داخل الوظيفة ، وليس في أي مكان بالخارج.
فيما يلي الحل الأساسي للتعليمات البرمجية لإنشاء متغير `myVar` محلي.
`function myLocalScope() {
var myVar;
console.log(myVar);
}
myLocalScope();
`
المتغير موجود فقط في الوظيفة. خارج الوظيفة ، هو غير موجود.