- Nomad Coder - 바닐라 JS로 크롬 앱 만들기 필기
var a = 'some'
let b = 2
const c = 3
const arrSome = '변수로 배열 추가'
const arr = [1, 2, 3, 4, 5, '배열', arrSome]
console.log(arr[5])
arr[5] = '변경'
console.log(arr[5])
arr.push('배열추가')
console.log(arr[6])
console.log(arr[7])
const isSome = false
if (isSome) {
console.log('True입니다.')
} else {
console.log('False입니다.')
}
const player = {
name: 'park',
age: 34,
email: '11111@naver.com',
}
console.log(player.name + ' ' + player.age + ' ' + player.email)
function sayHello(name, age) {
console.log('hello! my name is ' + name + ' my age is ' + age)
}
sayHello('park', 34)
sayHello('ham', 33)
sayHello('lee', 30)
sayHello('choi', 29)
let someName = 'ham'
let someAge = '30'
const player1 = {
name: someName,
age: someAge,
sayHello1: function (otherName) {
console.log('hello! nice to meet you ' + otherName)
},
email: '1111@naver.com',
}
console.log(player1.name)
player1.hobby = 'exercise'
console.log(player1.hobby)
player1.sayHello1('nico')
const foreignAge = 34
function calkorAge(foreignAge) {
return foreignAge + 2
}
const korAge = calkorAge(foreignAge)
console.log(korAge)
const calculator = {
add: function (a, b) {
return a + b
console.log('hello')
},
minus: function (a, b) {
return a - b
},
multify: function (a, b) {
return a * b
},
divide: function (a, b) {
return a / b
},
powerof: function (a, b) {
return a ** b
},
}
const a1 = 2
const b1 = 3
const rsltAdd = calculator.add(a1, b1)
const rsltMinus = calculator.minus(a1, b1)
const rsltMultify = calculator.multify(a1, b1)
const rsltDivide = calculator.divide(a1, b1)
const rsltPowerOf = calculator.powerof(a1, b1)
const resltArr = [rsltAdd, rsltMinus, rsltMultify, rsltDivide, rsltPowerOf]
for (let index = 0; index < resltArr.length; index++) {
const element = resltArr[index]
console.log(element)
}