var binary = 0b01000001;
var octal = 0o101;
var hex = 0x41;
console.log(binary, octal, hex)
console.log(binary == octal)
console.log(binary == hex)
console.log(Number.NEGATIVE_INFINITY)
console.log(Number.NaN == 1 * "abcd")
console.log(3/0)
console.log(-3/0)
console.log(0/0)
console.log(1 * "abcd")
console.log(Number.NaN == Number.NaN)
console.log("======================")
var temp = `temp literal
asdfasdf`;
console.log(temp)
var str = 'abcd efg\nbc'
console.log(str)
var first = "승종";
var last = "김"
console.log('My name is ' + first + ' ' + last + '.')
console.log('My name is ${first} ${last}.')
console.log(`My name is ${first} ${last}.`)
console.log(`1234 * 567 = ${1234 * 567}`)
console.log(!!10)
console.log(!10 == 0)
for(var i = 5 ; i-- ; ) {
console.log(i)
}
console.log("======================")
console.log(10, !!10)
console.log(0, !!0)
console.log("abcd", !!"abcd")
console.log("", !!"")
console.log(null, !!null)
console.log("null", !!"null")
console.log(NaN, !!NaN)
console.log(undefined, !!undefined)
console.log("=====================")
var num1 = 10
var num2 = new Number(10)
console.log(num1 == num2) // 값만 비교
console.log(num1 === num2 / 1) // 타입, 값 비교
console.log(5 == '5')
console.log(5 === '5')
console.log(5 == true)
// 형변환
var str = "1234"
var num = Number(str)
var bool = Boolean(str)
console.log(num, typeof num)
console.log(bool, typeof bool)
// 숫자 >> 문자열
var str2 = String(num)
// 숫자 >> 불린
// 문자열 >> 불린
var bool = Boolean(str)
// 불린 >> 숫자 :: /1
// 불린 >> 문자열 :: +""
console.log(true / 1)
console.log(false / 1)
// unddefined
// null
console.log(undefined/1)
console.log(null/1)
console.log({}/1)
console.log(function() {} / 1)
console.log(-0 === 0)
console.log(Object.is(-0, +0)) // 이진법 저장시 부호비트
console.log(NaN === NaN)
// true && false > false
// 피연산자에 따른
// 형변환 떄문에
// sNaN && 1
console.log("abcd" && 1)
console.log(1 && "abcd" )
var a = 1 ? 2 : 3
console.log(a)
console.log("=================")
var obj = {x:1, y:2}
obj.z = 3;
delete obj.x
console.log(obj)
for(var i in arr){
console.log(arr[i])
}
for(var i in obj){
console.log(obj[i])
}
댓글