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