5 == 5 // true
5 == '5' // true
5 === 5 // true
5 === '5' // true
5 != 5 // false
5 != '5' // false
5 !== 5 // false
5 !== '5' // true
2 + 2 // 4
4 - 2 // 2
2 * 3 // 6
4 / 2 // 2
let a = 10; log(++a, a) // 11 11
let b = 10; log(b++, b) // 10 11
let c = 10; log(--c, c) // 9 9
let d = 10; log(d--, d) // 10 9
let a = 20; a += 5; // a = 25
let b = 20; b -= 5; // a = 15
let c = 20; c *= 5; // a = 100
let d = 20; d /= 5; // a = 4
let e = 20; e %= 5; // a = 0
(5 === 5) ? : 'a' : 'b' // a
3 > 2 && 1 < 2 // true
3 > 2 || 1 < 2 // true
!true // false
3 > 3 // false
3 < 3 // false
3 >= 3 // true
3 <= 3 // true
3 % 3 // 1
/* object Declaration */
const twit = {
name : "Proful", // any type
follower : 4817,
1 : "hi" // converted to string
}
/* Dot Notation */
twit.name // "Proful"
twit.follower // 4817
twit.follower.count
// Accessing nested props
/* Squre Notation */
twit['name'] // "Proful"
// can be dynamic/ variable
const {name, followers} = twit
name // Proful
followers // 4800
const linkedin = { name }
{ name : 'Priful' }
// Empty object creations
const person = {}
const person = new Object()
const twit = {
name : "Proful"
}
function change(insta) {
insta.name = "Steve"
}
change(twit)
twit.name // "Steve"
delete twit.name // both key & value
twit.randomKey // undifined
twit.follower = 5000 // declared as const but mutable
for(const key in twit) {
console.log(key) // name
// followers
}
const twit = {
name : "Proful",
get progile() { // getter
return `Hi ${this.name.toLowerCase()}`
},
set profile(prof) {
this.name = "Mr " + prof
} // Seter
}
twit.profile // 'Hi proful'
twit.profile // = 'Steve'
twit.profile // 'Hi Steve'
const twit = {
name: "Proful",
hi() {
console.log(`Hi ${this.name}`) // this refer to twit object
},
hello: () => {
console.log(`Hello ${twit.name}`) // You cannot use this here
},
}
자기 전에 새해 다짐 겸, 내가 여지껏 배웠던 자바스크립트 기본 문법들 중 가장 기초적인 것들만 정리해보았다. 당장 눈앞의 리액트 공부가 중요한것도 사실이지만, 그래도 바닥공사를 확실하게 한 번 해보는 시간을 가지는 것이 절대로 허튼시간이라고 생각하지 않는다. 내일부터 다시 내가 만든 미니프로젝트 및 리엑트 공부를 할 생각하니 설레면서 또 내가 다시 게을러질까봐 두렵다. 외국에 현업으로 개발하는 친구들에게 조언을 구해보니
코딩이란건 많은 케이스의 오류를 부딪혀 보는 것과 나의 성장이 비례하다. 그래서 내가 틀렸을 때 낙담하고 좌절할 필요가 없다. 내가 틀림을 보는 것이 곧 성장이다.
이런식의 말을 공통적으로 하였다. 솔직히 난 여전히 내가 한 번에 코드구현을 하지 못할때나 메소드가 기억나지 않아서 구글링을 할 때 마다 내가 바보같이 느껴져서 쉽게 낙담하기 때문에 전부다 공감할 수 없는 말이다. 하지만 저게 사실이라면 나같은 사람은 매우 성장할 확률이 높다는 것이라고 긍정적으로 생각하기로 결심했다.
결론 : 오류가 곧 기회다 !
는 무슨 에러 뜰 때마다 마상..... 😭