week1

지혜리·2021년 8월 23일
0

TIL

목록 보기
2/5
post-thumbnail

01 console.log[출력]

값을 눈에 보이도록 화면에 나타내는 것.
어떤 대상이나 값을 화면에 띄우는것.

console.log 명령어 입력 -> ( ) 소괄호 안에 값 입력.
'콘솔로그 찍어본다' 로 많이 표현.

ex) console.log (출력할 대상);
console.log ('hello');

02-1 variable[변수]

데이터를 담을 수 있는 대상
특정한 대상을 담아서 사용할 수 있는것.

ex) mynumber (변수이름) = 100 (변수에 담긴 값) ;

2가지 방법 :
Declare(선언) : let mynumber
Assign (할당)대입 : mynumber = 100 ;
한번에 이루어짐 -> let mynumber=100; 동시에 declare과assign .

02-2 데이터 타입

기본타입(primitive type): number,string,boolean,underfined,null

  1. number 숫자 0 1 500 10000 콘솔로그 순서에 따라 순서대로 출력됨
    (+,-,/,
    .%)연산에 대한 결과를 출력할수있다. 숫자라서 가능

2.string 아무 문자 전부 다 해당 ' ' <-양쪽에 ' 이용

ex) consol.log ('coffee')

'string'과 number 을 같이 활용할수있다 , (콤마)를 이용해서 나눠줄것.
ex) consol.log(' number1 ',number1) -> number1 100 으로 출력

3.boolean 참1과 거짓0 구별 할때,
true
false

4.undefined&null 정의가 되지않은 , 없다

참조타입(reference type): array,object,function

  1. array 값이 일렬로 모여있는,
    [ ] 대괄호 안에 배열
    ex) let myarray=[19,44,'good',false]

  2. object객체 데이터가 모여있는 묶음,
    { } 중괄호사용, 특정한 데이터를 저장할때 앞에 키(name)를 붙인다,

3.function 함수
ex)function myfunction( ) {let name='code kim' ,console.log(name) return name}

03 string[문자열]

(공백 띄어쓰기도 포함됨)

문자열 서로 합치기
ex) consol.log ('hello world' + ' ' + 'code kim')

*넘버데이터랑 + 스트링 데이터랑 합치면 ->
스트링 데이터가 된다.
ex) consol.log (2 +'2') -> 22
number string

*문자열의 총 길이 구하기 string length
ex) consol.log('pepsi'.length) -> 5

04-1_function1 함수선언과 호출

input -> function -> output
값 기능 결과도출
input받기 기능수행 output반환

선언을 하고 시작함. 그 다음 실행 (= 정의를 하고 호출 한다.)
ex)
정의 : function 함수의이름 (input자리) { consol.log('수행할기능') }
호출 : 함수이름 ( ) 소괄호를 붙여주면 호출됨.

ex) function sayHello (){console.log ('Hello! code kim!) }
정의를 했으면
그 다음 호출!
sayHello () <- 호출

profile
코린이

0개의 댓글