분류 전체보기67 JavaScript function level up #Scope Scope refer to variable 'visibilty', basically the location where a variable is defined dictates where we have access to that variable. function collectEgg(){ let totalEggs=6; console.log(totalEggs) } collectEggs(); // 6 If you run this function, totalEggs number is printed on console. But if you move console.log(totalEggs) to outside function, this code makes just an error. What if you r.. 2022. 10. 13. JavaScript Function # Intro Functions Functions is reusable a chunk of code that we can then execute at a later point. It allows us to write reusable, modular code. There's two steps which is define and run. These process is critical that we define the function and then we execute it afterwards. In js, there is something like hoisting, so the function could be running even thought it defined later. But always try t.. 2022. 9. 28. JavaScript Loop # For loop The whole point of looping is repeating some functionality. ex) print 'hello' 10times / sum all numbers in an array. There are multiple types of loops : for / while /for...of/for...in for( [initialExpression]; [condition]; [incrementExpression]; ) for(let i = 1; i targetNum){ guess= prompt('Too high! Enter a new guess!') }else{ guess= prompt('Too low! Enter a new guess!') } } if(guess.. 2022. 9. 13. JavaScript Object Literals # Intro Object Literals Objects are collections of properties. Properties are a key-value pair. It is like little pieces of data where there's not an order, there's not a priority. It is just the pairs. So we can store whatever we want Rather than accessing data using an index, we use custom keys. We can instead lable thinks there's not really an order here that matters. It is all about labeling.. 2022. 9. 9. 이전 1 ··· 5 6 7 8 9 10 11 ··· 17 다음