A first splash into JavaScript__MDN

0

매일 탐구한 MDN 문서를 내맘대로 요약한다!

초심자의 경우
여러 영상을 통해 선학습 한 뒤, MDN document 를 읽으면,
학습한 내용을 정리하는데 도움이 된다.

이 방법은 한 챕터를 여러번 보기 때문에 갱장히 오랜 시간이 걸린다는 점 참고 🎶 ~~
꼼꼼한 사람 추천! ~~꼼꼼이라 쓰고 집요라고 읽는다.

Youtube 드림코딩 엘리님 또는 생활코딩 또는 노마드코더 추천!

✔️START __

Adding variables to store our data

-What is a variable?

: Variable is a container for a value.

<button id="button_A">Press me</button>
    <h3 id="heading_A"></h3>

const buttonA = document.querySelector('#button_A');
    const headingA = document.querySelector('#heading_A');
    
    buttonA.onclick = function() {
      let name = prompt('What is your name?');
      alert('Hello ' + name + ', nice to see you!');
      headingA.textContent = 'Welcome ' + name;
    }

-*Declaring a variable! __ all code instructions should end with a semi-colon(;)*

  • let / var

  • followed by a name for your valuable

  • let was created in modern versions.

  • var can declare the same variable as many times as you like, but with let you can't ! *It just makes things more confusing.

▶️ Recommend that use let as much as possible in your code.

-An aside on variable naming rules

  • Don't use underscore at the start of variables
  • Don't use the numbers at the start of variables
  • Good name examples:
age
myAge
init
initialColor
finalOutputValue
audio1
audio2

keywords__ A fairly complete list of reserved keyword to avoid at Lexical grammar

-Variable types

  • Numbers
    a) integers, decimal(like 2.456)
    b) You don't need to declare variable types & don't include quotes
  • Strings
    a) pieces of text
    b) single or double quote marks 'hi' or "hi"
let dolphinGoodbye = "So long and thanks for all the fish" ;
  • Booleans
    a) True or False values
    b) after which code is run as appropriate
let test = 6 < 3;

//It returns false
  • Arrays
    a) single object that contains multiple values enclosed in square brackets
    b) separated by commas
let myNameArray = ['Chris', 'Bob', 'Jim'];
let myNumberArray= [10, 15, 20]; 

myNameArray[0]; //should return 'Chris' __ index start 0. 0 ,1, 2
myNumberArray[2]; //should return 20
  • Objects
    a) structure of code that models a real-life object
    b) contains information
let dog = { name:'happy' , breed:'Dalmatian'};

dog.name //to retrieve the information strored in the object
  • const

    : Used to store values that are immutable or can't be changed !

const daysInWeek = 7;
const hoursInDay= 24; 

0개의 댓글