Java Script
-
[ Codecademy ] lodashJava Script 2020. 7. 27. 14:30
const _ = { clamp (number, lower, upper) { const lowerClampedValue = Math.max(number, lower); const clampedValue = Math.min(lowerClampedValue, upper); return clampedValue ; }, inRange(number, start, end) { if ( end === undefined ) { end = start; start = 0; } if ( start > end ) { const temp = end end = start ; start = temp; } const isInRange = start = length) { return string; } const startPadding..
-
CODE CHALLENGES: INTERMEDIATE JAVASCRIPTJava Script 2020. 7. 22. 16:23
1. reverseArray() const reverseArray = arr => { let reversed = []; for (let i = arr.length-1; i >= 0; i--) { reversed.push(arr[i]) } return reversed; } const sentence = ['sense.','make', 'all', 'will', 'This']; console.log(reverseArray(sentence)) /* [ 'This', 'will', 'all', 'make', 'sense.' ] */ 2. greetAliens() ===.forEach const greetAliens = (arr) => { for (let i=0; i { let newArray=[] for (le..
-
자꾸 끝에 undefined가 찍힐 때,Java Script/디버그 2020. 7. 21. 15:52
const veggies = ['broccoli', 'spinach', 'cauliflower', 'broccoflower']; const politelyDecline = (veg) => { console.log('No ' + veg + ' please. I will have pizza with extra cheese.'); } const declineEverything = veg => { veg.forEach(politelyDecline); } console.log(declineEverything(veggies)); const acceptEverything = veg => { veg.forEach(veg=>{ console.log(`Ok, I guess I will eat some ${veg}.`) }..
-
객체 2 (ADVANCED OBJECTS)Java Script 2020. 7. 14. 15:08
1. this Keyword 어떠한 의미가 고정되어 있지 않고 그것을 사용하는 상황에 따라서 그 의미는 달라질 수 있다 가변적이다. const goat = { dietType: 'herbivore', makeSound() { console.log('baaa'); } }; /* goat.makeSound(); // Prints baaa const goat = { dietType: 'herbivore', makeSound() { console.log('baaa'); }, diet() { console.log(dietType); } }; goat.diet(); // Output will be "ReferenceError: dietType is not defined" why is dietType not defi..
-
Object 객체Java Script 2020. 7. 9. 16:47
https://www.youtube.com/watch?v=MiLELE_yskc 1. 객체 작성 방법 2. 객체 접근 방법 2.1 dot operator let spaceship = { homePlanet: 'Earth', color: 'silver', 'Fuel Type': 'Turbo Fuel', numCrew: 5, flightPath: ['Venus', 'Mars', 'Saturn'] }; let crewCount = spaceship.numCrew; console.log(crewCount); //5 let planetArray = spaceship.flightPath ; console.log(planetArray);// ['Venus', 'Mars', 'Saturn'] 2.2 Bracket Not..
-
Mini LinterJava Script 2020. 7. 8. 17:36
let story = 'Last weekend, I took literally the most beautiful bike ride of my life. The route is called "The 9W to Nyack" and it actually stretches all the way from Riverside Park in Manhattan to South Nyack, New Jersey. It\'s really an adventure from beginning to end! It is a 48 mile loop and it basically took me an entire day. I stopped at Riverbank State Park to take some extremely artsy pho..
-
iterators 반복자Java Script 2020. 7. 8. 15:15
반복자 하나하나를 꺼내서 하나하나 어떠한 처리를 할 수 있도록 해주는 역할을 하는 것 1. .forEach() Method = function printGrocery(element){ console.log(element); } groceries.forEach(printGrocery); = groceries.forEach(groceryItem => console.log(groceryItem)); const fruits = ['mango', 'papaya', 'pineapple', 'apple']; fruits.forEach(function(fruits) { console.log("I want to eat a " + fruits ); }); // I want to eat a mango I want to ea..
-
자바스크립트 용어 정리Java Script 2020. 7. 3. 15:42
Methods 매서드 : JS 가 가지고 있는 데이터 타입이나/객체뒤에 붙어서 동작하는 함수 예 ) .length console.log('Teaching the world how to code'.length) Variable 변수 : 계속 변하는 값 예 : let / const / var Operators 연산자 : 수학적인 것을 다루거나 문자열을 결합 예 : +,-,%,*,++, ===,!==, || Function 함수 - Function Parameters 함수 매개변수 : 함수 선언 안에 나열된 이름(names) - Arguments 인자 : 함수에서 넘겨 받은 실제 값(values)