Module 1: KEYWORD let IN AND OUT..................

Qaybta Xirfada Sayniska iyo iwm

Moderators: Moderators, Junior Moderators

User avatar
afisoone
SomaliNet Super
SomaliNet Super
Posts: 5509
Joined: Wed Jul 22, 2009 9:46 pm
Location: We all want to become president even though Amisom controls Mogadishu

Module 1: KEYWORD let IN AND OUT..................

Post by afisoone »

variables waxaa lagu dhisaa program kasto aad ku qoreeysid javascript. Maanta waxaan rabaa inaa sharaxo asagoo dhan iyo scope kiisa oo dhan.

let's do the first one................

Code: Select all

[quote]let qor="Saciid Afisoone";
let outside="meelkasto waa loogu wici karaa";
console.log(qor);[/quote]
Variablekaan qor iyo outside waxaa laseemeeyay [before if statement or curly braces]. That means waa access kareen kartaa inside and outside[if statements or curly braces kasto ama function ha ahaado ama san yuu ahaanee.

here is the evidence.

Code: Select all

[quote]if(qor==="Saciid Afisoone")
{
	console.log(outside);
	
}
[/quote]
You see we access the variable outside inside if statements. That proves any variable declared before if statement or anything with curly braces can be access inside if statements or curly braces.

Now what about if we a new variable inside the if statements or inside curly braces. Then you can only access inside if statements or curly braces only and only and here is the evidence.

Code: Select all

[quote]if(qor==="Saciid Afisoone")
{
	console.log(outside);
	let inside="you can access only here";
	console.log(inside);
}[/quote]
Now when we run it we access the variable inside because we call it inside the if statement or the curly braces. but if we call outside of the if statements or curly braces, we will get error.

here is the evidence...

Code: Select all

[quote]if(qor==="Saciid Afisoone")
{
	console.log(outside);
	let inside="you can access only here";
	console.log(inside);
}


console.log(inside);[/quote]
you see here is the rule: Variables that is defined outside if statements or curly braces can be access inside if statements or curly braces, but if variables is defined inside if statements or curly braces can only access inside that if statements or curly braces.
That is what is block of scope is.

Ok. That is all about javascript 6 also you can var or const.

So here is full document about variable let.... and keep it copy and paste and save it... now you are ready the next module.

here is the full page..

Code: Select all

[quote]<!doctype html>
<html>
<meta charset="utf-8">
<head>
<title>Isticmaalka variableka let</title>
</head>
<body>
<script type="text/javascript">

let qor="Saciid Afisoone";
let outside="meelkasto waa loogu wici karaa";
console.log(qor);
if(qor==="Saciid Afisoone")
{
	console.log(outside);
	let inside="you can access only here";
	console.log(inside);
}


console.log(inside);

</script>


</body>
</html>[/quote]
That module one..

Written by
Macalin Afisoone
User avatar
afisoone
SomaliNet Super
SomaliNet Super
Posts: 5509
Joined: Wed Jul 22, 2009 9:46 pm
Location: We all want to become president even though Amisom controls Mogadishu

Re: Module 1: KEYWORD let IN AND OUT..................

Post by afisoone »

Remember [qoute] lamasocdo codeka. Next module I will correct for now here

is the correct full let keyword module1.

Code: Select all

<!doctype html>
<html>
<meta charset="utf-8">
<head>
<title>Isticmaalka variableka let</title>
</head>
<body>
<script type="text/javascript">

let qor="Saciid Afisoone";
let outside="meelkasto waa loogu wici karaa";
console.log(qor);
if(qor==="Saciid Afisoone")
{
	console.log(outside);
	let inside="you can access only here";
	console.log(inside);
}


console.log(inside);

</script>


</body>
</html>
Post Reply
  • Similar Topics
    Replies
    Views
    Last post

Return to “Careers - Engineering, Science & Computers”