Study/JavaScript
-
The switch keywordStudy/JavaScript 2020. 4. 29. 18:05
The switch keyword else if statements are a great tool if we need to check multiple conditions. In programming, we often find ourselves needing to check multiple values and handling each of them differently. For example: let groceryItem = 'papaya'; if (groceryItem === 'tomato') { console.log('Tomatoes are $0.49'); } else if (groceryItem === 'papaya'){ console.log('Papayas are $1.29'); } else { c..
-
String InterpolationStudy/JavaScript 2020. 4. 29. 10:26
String Interpolation In the ES6 version of JavaScript, we can insert, or interpolate, variables into strings using template literals. Check out the following example where a template literal is used to log strings together: const myPet = 'armadillo'; console.log(`I own a pet ${myPet}.`); // Output: I own a pet armadillo. Notice that: a template literal is wrapped by backticks ` (this key is usua..
-
Create a Variable: letStudy/JavaScript 2020. 4. 29. 09:54
Create a Variable: let As mentioned in the previous exercise, the let keyword was introduced in ES6. The let keyword signals that the variable can be reassigned a different value. Take a look at the example: let meal = 'Enchiladas'; console.log(meal); // Output: Enchiladas meal = 'Burrito'; console.log(meal); // Output: Burrito Another concept that we should be aware of when using let (and even ..
-
Create a Variable: varStudy/JavaScript 2020. 4. 29. 09:39
Create a Variable: var There were a lot of changes introduced in the ES6 version of JavaScript in 2015. One of the biggest changes was two new keywords, let and const, to create, or declare, variables. Prior to the ES6, programmers could only use the var keyword to declare variables. var myName = 'Arya'; console.log(myName); // Output: Arya Let’s consider the example above: var, short for variab..
-
PropertiesStudy/JavaScript 2020. 4. 28. 22:11
Properties When you introduce a new piece of data into a JavaScript program, the browser saves it as an instance of the data type. Every string instance has a property called length that stores the number of characters in that string. You can retrieve property information by appending the string with a period and the property name: console.log('Hello'.length); // Prints 5 The . is another operat..
-
Data TypesStudy/JavaScript 2020. 4. 28. 21:49
Data Types Data types are the classifications we give to the different kinds of data that we use in programming. In JavaScript, there are seven fundamental data types: Number: Any number, including numbers with decimals: 4, 8, 1516, 23.42. String: Any grouping of characters on your keyboard (letters, numbers, spaces, symbols, etc.) surrounded by single quotes: ' ... ' or double quotes " ... ". T..
-
CommentsStudy/JavaScript 2020. 4. 28. 21:48
Comments Programming is often highly collaborative. In addition, our own code can quickly become difficult to understand when we return to it— sometimes only an hour later! For these reasons, it’s often useful to leave notes in our code for other developers or ourselves. As we write JavaScript, we can write comments in our code that the computer will ignore as our program runs. These comments ex..
-
error:: Cannot read property () of null 넌.. 누구니...?!Study/JavaScript 2020. 4. 23. 14:03
내가 이 에러친구 때문에 2시간을 헤매었다... ㅎㅎㅎ 이 에러친구는 처음만났기 때문에 뭐가 문제인지, 어떻게 해결해야하는지 몰랏기 떄문이다. 아마 JS 입문자여서 더욱이 문제해결능력이 떨어졌던 것 같다. 무튼 이 친구가 나의 JS 첫 문제상황!!! (반갑다 친구야🤔) 구글링을 해보니 다양한 해결책이 주어져있었다. 그러나 내 상황에 해당되는 것 같지는 않았다. 그래서 다시 또 구글링!! 드디어, 나에게 맞는 해결책을 찾았다!! annot read property 'val' of null 오류 발생, 개발자들 사이에서도 자바스크립트 내에서도 가장 자주 발생하는 오류라고 한다. 해결 방법 : 아마 자바스크립트 구문이 위에 있는 경우에 많이 발생하는듯함. 읽는 위치에 따라 해석이 달라지는데, 따라서 테스트..