전체 글
-
7. Array, APIJavaScript & TypeScript 2020. 11. 14. 14:17
Array 1. Declaration const arr1 = new Array(); const arr2 = [1, 2]; 2. Index position const fruits = ['apple', 'banana']; console.log(fruits); // 'apple', 'banana' console.log(fruits.length); // 2 console.log(fruits[0]); // 'apple' console.log(fruits[1]); // 'banana' console.log(fruits[2]); // undefined console.log(fruits[fruits.length - 1]); // 'banana' 3. Looping over an array print all fruits..
-
6. what is objectJavaScript & TypeScript 2020. 11. 14. 12:31
Objects one of the JavaScript's data types a collection of related data and/or functionality Nearly all objects in JavaScript are instances Object object = { key : value }; 1. Literals and properties const obj1 = {}; // 'object literal' syntax const obj2 = new Object(); // 'object constructor' syntax function print(person) { console.log(person.name); console.log(person.age); } const ellie = {nam..
-
boj)2447 - 별 찍기 - 10PS/boj 2020. 11. 14. 12:15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 import java.io.*; import java.util.Scanner; public class boj_2447 { static char[][] map; static int length; static Scanner sc = new Scanner(System.in); static BufferedWriter bw = new BufferedWriter(new OutputStreamW..
-
boj)16505 - 별PS/boj 2020. 11. 14. 11:27
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 import java.io.*; import java.util.Scanner; public class boj_16505 { static char[][] map; static int N, length; static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); public static void main(String[] args) throws IOException { Scanner sc ..
-
5. class vs objectJavaScript & TypeScript 2020. 11. 14. 11:06
class template declare once no data in introduced in ES6 syntactical sugar over prototype-based inheritance 1. class declarations class Person { // constructor constructor (name, age) { // fields this.name = name; this.age = age; } // methods speak() { console.log(`${this.name}: hello! `); } } const ellie = new Person('ellie', 20); console.log(ellie.name); // ellie console.log(ellie.age); // 20 ..
-
4. Arrow FunctionJavaScript & TypeScript 2020. 11. 13. 18:04
Function fundamental building block in the program subprogram can be used multiple times performs a task or calculates a value 1. Function declaration function name(param1, param2) { body ... return; } one function === one thing naming: doSomething, command, verb e.g.createCardAndPoint ->. createCard, createPoint function is object in JS function printHello() { console.log('Hello'); } printHello..
-
3. operator, if, for loopJavaScript & TypeScript 2020. 11. 13. 17:40
1. String concatenation console.log('my' + ' cat'); // my cat console.log('1' + 2); // 12 console.log(`string literals: 1 + 2 = ${1 + 2}`); // 1 + 2 = 3 2. Numeric operators console.log(1 + 1); // add : 2 console.log(1 - 1); // substract : 0 console.log(1 / 1); // divide : 1 console.log(1 * 1); // multiply : 1 console.log(5 % 2); // remainder : 1 console.log(2 ** 3); // exponentiation : 8 3. Inc..
-
2. data types, let vs var, hoistingJavaScript & TypeScript 2020. 11. 13. 17:21
1. let vs var, hoisting Variable, rw(read/write) let (added in ES6) scope global scope block scope Var var (don't ever ues this) var hoisting (move declaration from bottom to top) has no block scope block scope ignore Constant, r (read only) favor immutable data type always for a few reasons security thread safety reduce human mistakes 2. data types Variable types primitive, single item number s..