Skip to content

Commit

Permalink
scope in function blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristi-Fogel committed Jan 5, 2025
1 parent ba40434 commit 106423f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions a_temp_deleteME/basics1.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,19 @@ let sumOfIntegers = function(c,d){
let sumOfNr = (c,d)=> c+d;
console.log("sum of nr: " + sumOfNr(3,4));

// function scope
var greet = "Global Level"; // global value
let greeting = "block level no matter what" // global value, but block value is prio
const constantValue = "you can't change me" //var + let can be reinitialized; but const will remain the same

function greet1(){
var greet = "Block level";
var greeting = "block level because i said so";
let niu = "not visible outside this block";

console.log(greet);
console.log(greeting);
console.log(niu);
console.log(constantValue);
}
greet1();

0 comments on commit 106423f

Please sign in to comment.