Learn Javascript -1 "Data Type"

minjoo kim·2020년 12월 20일
0

Data type

  • Number
  • String > 텍스트
  • Boolean
  • Null
  • Undefined
  • Symbol
  • Object
Console.log()
Code comments :
Single line comment : // sentence.
Multi line comment : /* sentences. */

console.log(“2011”) >텍스트로 인식
console.log(2011) >숫자로 인식

Does that syntax look a little familiar?
When we use console.log() we’re calling the .log() method on the console object. Object have methods.

Variable : var
Let
값을 할당하지 않고(= undefined), 변수를 선언할 수 있음.

let changeMe = true;
changeMe = false;
console.log(changeMe);
//->false

다음처럼

let levelUp = 10;
let powerLevel = 9001;
let multiplyMe = 32;
let quarterMe = 1152;

// Use the mathematical assignments in the space below:
levelUp += 5;
powerLevel -= 100;
multiplyMe *= 11;
quarterMe /= 4;

=15
=8901
=352
=288

Constant
값을 재 할당하려고 하면 에러. ‘일정(constant)’하기 때문임
그리고 값을 할당해야 함.

let w = 4;
w = w + 1;
 
console.log(w); // Output: 5

[Mathematical Assignment Operators]

+= 
-= 
*= 
/=
내장함수

[Increment and Decrement Operator]

++
—

[template literal]

const myPet = 'armadillo';
console.log(`I own a pet ${myPet}.`);
// Output: I own a pet armadillo.

var myName = 'minjoo';
var myCity = 'Sanfrancisco';
console.log(`My name is ${myName}. My favorite city is ${myCity}.`)

[typeof operator]

const unknown1 = 'foo';
console.log(typeof unknown1); // Output: string
 
const unknown2 = 10;
console.log(typeof unknown2); // Output: number
 
const unknown3 = true; 
console.log(typeof unknown3); // Output: boolean

0개의 댓글