Wecode day 4

Michael Minchang Kim·2020년 4월 23일
0

wecode

목록 보기
8/22

Exceptions

Exceptions are used when you want to catch an error and prevent the code from exiting. User inputs increase the chance of errors happening. If the user enters in

Javascript

1. Basics

This makes an alert box pop out with the string inside.

alert("some word");

This makes the string show in the console. Kind of like a print statement.

console.log();

2. Commenting

Commenting is used when you want to write text in code that isn't code.

single line comments

// 주석달 때는 slash 두개로 시작합니다. 

multiline comments

/* 두 줄 이상 주석 처리하려면, 
잘 막아주세요 */

3. Variables

Use let for variables that can be changed and const for constant values.

4. Functions

5. Arrays

Arrays are same as python, you can add any variable you want no matter the type.

a. adding new elements

When adding new elemets, you can add elements to specific locations.

cities[5] = "제주도";

Even if the list is empty this is possible. The empty locations will return undefined

b. push/unshift

The push method will add the new element to the end of the list.
The unshift method will add the new element to the front of the list.

let cities = [];
cities.push("경주", "전주");
cities.unshift("인천");

c. pop

The pop method will delete the last element of the list and return it.

6. Coding Convention

링크텍스트

7. Date and Time

Date and Time is used alot in Front end developement

a. Date

var rightNow = new Date();
console.log(rightNow);

--result--
2019-02-18T00:45:06.562Z

Time is typically organized as such

So how do you get parts of the date?

Code

let rightNow = new Date();
let year = rightNow.getFullYear();
let month = rightNow.getMonth()+1;
let date = rightNow.getDate();
let day = rightNow.getDay();
let currentHour = rightNow.getHours();
let currentMin = rightNow.getMinutes();	

Result

rightNow : Thu Apr 23 2020 20:48:12 GMT+0900 (Korean Standard Time)
year : 2020
month : 4
date : 23
day : 4
currentHour : 20
currentMin : 48

8. Math

List of math methods

Math.round();
Math.ceil();
Math.floor();
Math.random();

9. Objects

Same as dictionary

profile
Soon to be the world's Best programmer ;)

0개의 댓글