Skip to content

Instantly share code, notes, and snippets.

@shershen08
Created July 20, 2022 17:42
Show Gist options
  • Save shershen08/20ee28846030b019a92bd87cb04edd11 to your computer and use it in GitHub Desktop.
Save shershen08/20ee28846030b019a92bd87cb04edd11 to your computer and use it in GitHub Desktop.
JS overview
const add = (a,b) => a + b
const result = add(2, 2)
console.log(add(2, 2))
console.log(result)
// Number
// // BigInt
// String
// Boolean
// null
// undefined
// //Symbol
// Object
// const foo = 4.5
// const baa = 'Hello'
// const fff = function(){}
// const fooViaConst = Number(4.5)
// const baaViaConst = String('some string')
// es2015
// var
// let, const
class Shape {
#privateX
constructor (id, x, y) {
this.id = id
this.#move(x, y)
this.#privateX = 42
}
#move (x, y) {
this.x = x
this.y = y
}
revealPrivateX(){
return this.#privateX
}
static someMethod(){
return 42
}
set x(value) {
this._x = value
}
get x() {
return this._x
}
}
class Rectangle extends Shape {
#privateX
constructor (id, x, y, width, length) {
super(id, x, y)
this.id = id
this.#move(x, y)
this.#privateX = 42
}
#move (x, y) {
this.x = x
this.y = y
}
}
const sh = new Shape(1,2,3)
console.log(sh)
console.log(sh.x)
console.log(sh.revealPrivateX())
console.log(Shape.someMethod())
const rect = new Rectangle(1,2,3,4,5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment