[ ES5 ]
function BbangFrame(zearyo1, zearyo2){
this.base = zearyo1;
this.main = zearyo2;
}
var creambbang = new BbangFrame('๋ฐ๊ฐ๋ฃจ', 'ํฌ๋ฆผ')
console.log(creambbang)
var strawberrybbang = new BbangFrame('์๊ฐ๋ฃจ','๋ธ๊ธฐ')
console.log(strawberrybbang)
[ ES6 ]
class BbangFrame2{
constructor(zearyo1,zearyo2){
this.base = zearyo1;
this.main = zearyo2;
}
}
let patbbang = new BbangFrame2('๋ฐ๊ฐ๋ฃจ','ํฅx2')
console.log(patbbang)
// var , let, const : ๋ณ์ ์ ์ธ ์ธ๋ฐ
// let, const ๋ es6 ์์ ๋์จ๊ฑฐ๋ค.
// ๊ทผ๋ฐ ์ es5(2012) ๋ ์์์ผ ํ๋?
// ์ต๊ทผ ์ฝ๋๋ง ๋ง์ง๋ค๋ ๋ณด์ฅ์ด ์๋ค...
//
[๊ฒํฐ ์ธํฐ]
let myname = {
name: "๋ก๋ก",
lastname: "๊น",
get fullName(){
return `${this.lastname} ${this.name}`;
},
set fullName(value){
[this.lastname, this.name] = value.split(" ");
}
};
get fullName(){
return `${this.lastname} ${this.name}`;
}
,
set fullName(value){
[this.lastname, this.name] = value.split(" ");
}
[์๋ ์์]
[ typescript ]
private
- ํด๋์ค ๋ด๋ถ, ์์ ํด๋์ค ๋ด๋ถ, ํด๋์ค ์ธ์คํด์ค ๋ชจ๋ ์ ๊ทผ ๊ฐ๋ฅ
public
- ํด๋์ค ๋ด๋ถ์์๋ง ์ ๊ทผ ๊ฐ๋ฅ
class typetest {
public a: string;
private b: string;
constructor(x:string, y:string){
this.a = x;
this.b = b;
}
}
const typetest = new typetest('ํ์ด','๋ฐ์ด');
console.log(typetest.a); // ์ฐธ์กฐ ๊ฐ๋ฅ
console.log(typetest.b); // ์ฐธ์กฐ ๋ถ๊ฐ๋ฅ
[javascript] #
class javatest {
#a = 230512;
}
const javatests = new javatest();
console.log(javatests.#a);