๋กœ์ผ“๐Ÿพ
article thumbnail

 

 

ํšŒ์‚ฌ์— ์ธํ„ด์œผ๋กœ ์ž…์‚ฌ๋ฅผ ํ•˜๊ณ , ๋Œ€ํ‘œ๋‹˜๊ป˜์„œ ๊ณผ์ œ ํ•˜๋‚˜๋ฅผ ์ฃผ์…จ์Šต๋‹ˆ๋‹ค. ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ๋กœ ๊ฐ„๋‹จํ•œ ๊ณ„์‚ฐ๊ธฐ๋ฅผ ๋งŒ๋“œ๋Š” ๊ฒƒ์ด์˜€์Šต๋‹ˆ๋‹ค. ์–ด๋ ต์ง€ ์•Š๊ฒŒ ๊ตฌํ˜„์„ ํ•˜์˜€๊ณ , ๋Œ€ํ‘œ๋‹˜๊ป˜ ๋ณด์—ฌ๋“œ๋ ธ์Šต๋‹ˆ๋‹ค. ๊ณ„์‚ฐ๊ธฐ ๊ธฐ๋Šฅ ์ž์ฒด์—๋Š” ๋ฌธ์ œ๊ฐ€ ์ „ํ˜€์—†์—ˆ์œผ๋‚˜.. ๊ณ„์‚ฐ๊ธฐ๋ฅผ ๊ตฌํ˜„ํ•œ ์ฝ”๋“œ๋ฅผ ๋ณด์‹œ๊ณ ๋Š” ์ด๋Ÿฐ ๋ง์„ ํ•˜์…จ์Šต๋‹ˆ๋‹ค. ์•„์ง๋„ ์ •ํ™•ํžˆ ๊ธฐ์–ต๋‚ฉ๋‹ˆ๋‹ค. ์‹ฌ์ง€์–ด ๋งํˆฌ๊นŒ์ง€๋„ ๊ธฐ์–ต์ด ๋‚ฉ๋‹ˆ๋‹ค. 

 

์‚ฌ์ง„๊ณผ ๋‹ค๋ฅด๊ฒŒ ๋Œ€ํ‘œ๋‹˜์€ ํ‰์˜จํ•œ ๋งํˆฌ๋กœ ์–˜๊ธฐํ•˜์…จ์Šต๋‹ˆ๋‹ค. ์˜คํ•ด์—†์œผ์‹œ๊ธธ!!

"์ฝ”๋“œ์— ์ฒ ํ•™์ด ๋‹ด๊ฒจ ์žˆ์ง€ ์•Š์•„"

โ€ป์ฒ˜์Œ์— ์ œ๊ฐ€ ๊ตฌํ˜„ํ–ˆ๋˜ ์ฝ”๋“œ์ž…๋‹ˆ๋‹ค.

์ฝ”๋“œ๊ฐ€ ๋„ˆ๋ฌด ๊ธธ์–ด ๋งํฌ๋กœ ๋Œ€์ฒดํ•ฉ๋‹ˆ๋‹ค.

 

์–ผํ•๋ณด๋ฉด ๊ฐ€๋…์„ฑ๋„ ์žˆ๊ณ  ๋‚˜๋ฆ„๋Œ€๋กœ ํ•จ์ˆ˜ํ™”๋„ ์‹œ์ผœ์„œ ๋ฌธ์ œ๊ฐ€ ์—†์–ด ๋ณด์ผ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ ๋งŒ์•ฝ ๊ณ„์‚ฐ๊ธฐ์— ๋‚˜๋จธ์ง€๋ฅผ ๊ตฌํ•ด์ฃผ๋Š” % ๊ธฐ๋Šฅ์„ ์ถ”๊ฐ€ํ•ด์ฃผ๊ณ  ์‹ถ๋‹ค๋ฉด ๊ณ„์‚ฐ ๊ด€๋ จํ•œ ๋กœ์ง์œผ๋กœ ๋“ค์–ด๊ฐ€์„œ ๋‚ด๋ถ€๋ฅผ ๋œฏ์–ด๊ณ ์ณ์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๋ฌผ๋ก  ๊ณ„์‚ฐ๊ธฐ ๊ด€๋ จ ์ฝ”๋“œ๋„ ๋ณต์žกํ•˜๊ณ  ๊ธธ์ง€ ์•Š์•„์„œ ๋ฌธ์ œ๊ฐ€ ๋˜์ง€ ์•Š์ง€๋งŒ ์—ฌ๊ธฐ์ €๊ธฐ ์ข…์†์„ฑ์„ ๊ฐ€์ง€๋Š” ํ•จ์ˆ˜๋ผ๋ฉด ์ˆ˜์ •์‹œ ํฐ ๋ฌธ์ œ๊ฐ€ ๋ ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.

 

๊ทธ๋Ÿผ ๋Œ€ํ‘œ๋‹˜๊ป˜์„œ ๋ง์”€ํ•˜์‹  ์ฒ ํ•™์ ์ธ ์ฝ”๋“œ๋Š” ๋ฌด์—‡์ผ๊นŒ์š”?

 

https://www.edutopia.org/blog/critical-thinking-necessary-skill-g-randy-kasten

 

๊ฐ„๋‹จํ•œ ์˜ˆ๋กœ "๋ณ‘์ค€์ด๋Š” ์ถ•๊ตฌ๋ฅผ ์ข‹์•„ํ•œ๋‹ค.", "์ง€์›์ด๋Š” ๋ชฝ์ด๋ฅผ ์‚ฌ๋ž‘ํ•œ๋‹ค." ๋ผ๋Š” ๋ฌธ์žฅ์„ ์ฝ˜์†”์— ์ฐ๊ณ  ์‹ถ๋‹ค๊ณ  ๊ฐ€์ •ํ•ด๋ด…์‹œ๋‹ค.

 

์ƒ๋‹นํžˆ ์‰ฌ์šด ์˜ˆ์ œ์ž…๋‹ˆ๋‹ค.

console.log("๋ณ‘์ค€์ด๋Š” ์ถ•๊ตฌ๋ฅผ ์ข‹์•„ํ•œ๋‹ค.");
console.log("์ง€์›์ด๋Š” ๋ชฝ์ด๋ฅผ ์‚ฌ๋ž‘ํ•œ๋‹ค.");

 

์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ์‰ฝ๊ฒŒ ์ฝ˜์†”์— ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋ฌธ์žฅ์„ ์ถœ๋ ฅ์‹œํ‚ฌ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋ฌผ๋ก  ์ด๊ฒƒ๋„ ํ‹€๋ฆฐ ๋ฐฉ๋ฒ•์€ ์ ˆ๋Œ€ ์•„๋‹™๋‹ˆ๋‹ค. ์ €๋„ ๋ถˆ๊ณผ ๋ช‡ ๋‹ฌ์ „๋งŒํ•ด๋„ ์ €๋ ‡๊ฒŒ ์ฝ”๋“œ๋ฅผ ์งฐ์Šต๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ ์ €๋ ‡๊ฒŒ ์ฝ”๋“œ๋ฅผ ์งค ๊ฒฝ์šฐ ์žฌ์‚ฌ์šฉ์€ ๋ฌผ๋ก  ์œ ์ง€๋ณด์ˆ˜๋„ ๋ถˆ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.

(์•„์ฃผ ๊ฐ„๋‹จํ•œ ์˜ˆ์ œ์ด๊ธฐ์— ์ € ์ฝ”๋“œ๋ฅผ ์œ ์ง€๋ณด์ˆ˜ ํ•  ํ•„์š”๋„ ์žฌ์‚ฌ์šฉ ํ•  ํ•„์š”๋„ ์—†๊ฒ ์ง€๋งŒ..)

 

๋งŒ์•ฝ "๋ณ‘์ค€์ด๋Š” ์ถ•๊ตฌ๋ฅผ ์ข‹์•„ํ•œ๋‹ค"์—์„œ "์ง€์›์ด๋Š” ์ถ•๊ตฌ๋ฅผ ์ข‹์•„ํ•œ๋‹ค"๋กœ ๋ฐ”๊พธ๊ณ  ์‹ถ๋‹ค ํ•˜๋ฉด, console.log()์—์„œ ๋ฌธ์ž์—ด์„ ์ง์ ‘ ๋ฐ”๊ฟ€์ˆ˜๋„ ์žˆ๊ฒ ์ง€๋งŒ ์ € ์ฝ”๋“œ๊ฐ€ ์ƒ๋‹นํžˆ ๋ณต์žกํ•œ ๋กœ์ง์„ ๊ฐ€์ง„ ์ฝ”๋“œ๋ผ๊ณ  ์ƒ๊ฐํ•ด๋ด…์‹œ๋‹ค. ์—ฌ๊ธฐ์ €๊ธฐ ์ฝ”๋“œ๊ฐ€ ์–ฝํ˜€์žˆ์–ด์„œ ์ž์นซ ์ž˜๋ชป์ˆ˜์ •ํ•˜๋ฉด ํ”„๋กœ๊ทธ๋žจ ์ž์ฒด๊ฐ€ ๋‹ค์šด ๋ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

๋˜ ์ด๋ฒˆ์—๋Š” ์ € ์œ„์— ์žˆ๋Š” 2๊ฐœ์˜ ๋ฌธ์žฅ์ด ์•„๋‹Œ "๋ชฝ์ด๋Š” ๊ฐ„์‹์„ ์ข‹์•„ํ•œ๋‹ค"๋ผ๋Š” ๋ฌธ์žฅ์„ ์ถœ๋ ฅํ•˜๊ณ  ์‹ถ์Šต๋‹ˆ๋‹ค. console.log()๋กœ ์ถœ๋ ฅํ•˜๋ฉด ๋˜์ง€ ์•Š๋Š๋ƒ? ํ•˜์‹ค์ˆ˜๋„ ์žˆ๊ฒ ์ง€๋งŒ ์—ญ์‹œ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ ์ƒ๋‹นํžˆ ๋ณต์žกํ•œ ๋กœ์ง์„ ๊ฐ€์ง„ ์ฝ”๋“œ๋ผ๊ณ  ์ƒ๊ฐํ•ด๋ด…์‹œ๋‹ค. ์ด ๋˜ํ•œ ์ฝ”๋“œ๊ฐ€ ์–ฝํ˜€์žˆ์–ด์„œ ์ƒˆ๋กœ์šด ๋กœ์ง์„ ์ถ”๊ฐ€ํ•˜๊ธฐ๋ž€ ์‰ฝ์ง€ ์•Š์„ ๊ฒƒ์ž…๋‹ˆ๋‹ค.

 

์‰ฝ๊ฒŒ ๋งํ•ด, ์ฒ ํ•™์ ์ด์ง€ ์•Š์€ ์ฝ”๋“œ๋ž€

  • ์žฌ์‚ฌ์šฉ์ด ๋ถˆ๊ฐ€๋Šฅํ•˜๋‹ค
  • ์œ ์ง€๋ณด์ˆ˜๊ฐ€ ๋ถˆ๊ฐ€๋Šฅํ•˜๋‹ค
  • ์ฝ”๋“œ๊ฐ€ ๋งŽ์•„์งˆ ๊ฒฝ์šฐ ๊ฐ€๋…์„ฑ์ด ๋–จ์–ด์ง„๋‹ค.

๋ฐ˜๋Œ€๋กœ ์ฒ ํ•™์ ์ธ ์ฝ”๋“œ๋ž€?

  • ์žฌ์‚ฌ์šฉ์ด ๊ฐ€๋Šฅํ•˜๋‹ค
  • ์œ ์ง€๋ณด์ˆ˜๊ฐ€ ์‰ฝ๋‹ค
  • ๊ฐ€๋…์„ฑ์ด ์ข‹๋‹ค

 

์ฝ”๋“œ์— ์ฒ ํ•™์„ ๋‹ด๋‹ค!

 

์žฌ์‚ฌ์šฉ๊ณผ ์œ ์ง€๋ณด์ˆ˜๊ฐ€ ์šฉ์ดํ•˜๋ ค๋ฉด ์šฐ์„  ํ•จ์ˆ˜๊ฐ„ ๊ฒฐํ•ฉ๋„๊ฐ€ ๋‚ฎ์•„์•ผํ•ฉ๋‹ˆ๋‹ค. 

๋”ฐ๋ผ์„œ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๋‚˜๋ˆ„์—ˆ์Šต๋‹ˆ๋‹ค.

 

Language๋ผ๋Š” ๋ฌธ์žฅ์„ ๋งŒ๋“ค์–ด์ฃผ๋Š” ํ•จ์ˆ˜

 

// ๋ฌธ์žฅ์„ ๋งŒ๋“ค์–ด์ฃผ๋Š” ํ•จ์ˆ˜
        function language() {
            var _this = this;

            $(function(){
                _this.init();
                _this.subject();
                _this.verb();
                _this.object();
            });
        }

        language.prototype = {
            init : function(){
                console.log("lanaguage ๊ฐ์ฒด ์ƒ์„ฑ");
            },

            subject: function () {
                var sub_obj = {
                    bj: "๋ณ‘์ค€์ด๋Š”",
                    jw: "์ง€์›์ด๋Š”"
                }
                return sub_obj;
            },

            verb: function () {
                var verb_obj = {
                    like: "์ข‹์•„ํ•œ๋‹ค",
                    love: "์‚ฌ๋ž‘ํ•œ๋‹ค"
                }

                return verb_obj;
            },

            object: function () { //๋ชฉ์ ์–ด
                var obj_obj = {
                    soccer: "์ถ•๊ตฌ๋ฅผ",
                    puppy: "๋ชฝ์ด๋ฅผ"
                }

                return obj_obj;
            }
        }<

 

Language.prototype ์•ˆ์— ๋‚ด๋ถ€ ํ•จ์ˆ˜๋กœ ๊ฐ๊ฐ ์ฃผ์–ด, ๋™์‚ฌ, ๋ชฉ์ ์–ด์— ํ•ด๋‹นํ•˜๋Š” ๊ฐ์ฒด ํ•จ์ˆ˜๋ฅผ ๋งŒ๋“ค์—ˆ๊ณ , ๋˜ ๊ทธ ํ•จ์ˆ˜ ์•ˆ์—์„œ ํ•„์š”ํ•œ ๊ฐ ๋‹จ์–ด๋“ค์„ ๊ฐ์ฒด๋กœ ๋งŒ๋“ค์–ด์ฃผ์—ˆ์Šต๋‹ˆ๋‹ค.

 

showLog๋ผ๋Š” ์ฝ˜์†”์— ์ฐ์–ด์ฃผ๋Š” ํ•จ์ˆ˜๋ฅผ ๊ฐ€์ง„ ๊ฐ์ฒด

 

//console์— ์ฐ์–ด์ฃผ๋Š” ํ•จ์ˆ˜๋ฅผ ๊ฐ€์ง„ ๊ฐ์ฒด
var showLog = {
  init : function(){
    
  }
 ,consoleLog : function(sub, verb, obj){
     console.log(sub +" "+obj +" "+ verb);
 }
}

 

์ฝ˜์†”์— ์ฐ์–ด์ค„ ๊ธฐ๋Šฅ์„ ๊ฐ์ฒด(showLog)๋กœ ๊ตฌํ˜„ํ•˜์˜€๊ณ , ๊ฐ์ฒด๊ฐ€ consoleLog๋ผ๋Š” ํ•จ์ˆ˜๋ฅผ ๊ฐ–๊ฒŒ ํ•˜์˜€์Šต๋‹ˆ๋‹ค.

 

๊ทธ๋ฆฌ๊ณ  ๋งˆ์ง€๋ง‰์œผ๋กœ ํ•„๋“œ์— ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์„ ์–ธํ•˜์˜€์Šต๋‹ˆ๋‹ค.

 

var newLanguage = new language();

var sub = newLanguage.subject();
var verb = newLanguage.verb();
var obj = newLanguage.object();

showLog.consoleLog(sub.bj, verb.like, obj.soccer);
showLog.consoleLog(sub.jw, verb.love, obj.puppy);

 

์ƒ์„ฑ์ž๋ฅผ ํ†ตํ•ด ์ฃผ์–ด, ๋™์‚ฌ, ๋ชฉ์ ์–ด ๊ฐ์ฒด๋ฅผ ๋งŒ๋“ค์–ด์ฃผ์—ˆ๊ณ  , ๋งŒ๋“ค์–ด์ง„ ๊ฐ์ฒด๋“ค์— ํ•ด๋‹นํ•˜๋Š” ํ•จ์ˆ˜๋ฅผ ์ง€์ •ํ•œ ํ›„ ๋ณ€์ˆ˜๋ฅผ ์žฌ์ •์˜ํ•˜์˜€์Šต๋‹ˆ๋‹ค.

 

๊ทธ๋ฆฌ๊ณ  showLog ๊ฐ์ฒด๋ฅผ ์ด์šฉํ•˜์—ฌ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๊ฒฐ๊ณผ๋ฅผ ์ถœ๋ ฅํ•˜์˜€์Šต๋‹ˆ๋‹ค.

 

์ถœ๋ ฅ ๊ฒฐ๊ณผ

 

 

์ƒˆ๋กœ์šด ๋ฌธ์žฅ์„ ๋งŒ๋“ค๊ณ  ์‹ถ๋‹ค๋ฉด?

 

๋งŒ์•ฝ ์ƒˆ๋กœ์šด ๋ฌธ์žฅ์ธ "๋ชฝ์ด๋Š” ์ง€์›์ด๋ฅผ ์ข‹์•„ํ•œ๋‹ค"๋ฅผ ๋งŒ๋“ค๊ณ  ์‹ถ๋‹ค๋ฉด ์•„๋ž˜ ์ฝ”๋“œ์™€ ๊ฐ™์ด ํ•ด๋‹น ์ฃผ์–ด, ๋™์‚ฌ, ๋ชฉ์ ์–ด ๊ฐ์ฒด ํ•จ์ˆ˜์—  ์ƒˆ๋กœ์šด ๊ฐ์ฒด๋ฅผ ์ถ”๊ฐ€ํ•ด์ฃผ๋ฉด ๋ฉ๋‹ˆ๋‹ค. 

language.prototype = {
            init : function(){
                console.log("lanaguage ๊ฐ์ฒด ์ƒ์„ฑ");
            },

            subject: function () {
                var sub_obj = {
                    bj: "๋ณ‘์ค€์ด๋Š”",
                    jw: "์ง€์›์ด๋Š”",
                    puppy : "๋ชฝ์ด๋Š”" //=> ์ถ”๊ฐ€
                }
                return sub_obj;
            },

            verb: function () {
                var verb_obj = {
                    like: "์ข‹์•„ํ•œ๋‹ค",
                    love: "์‚ฌ๋ž‘ํ•œ๋‹ค"
                }

                return verb_obj;
            },

            object: function () { //๋ชฉ์ ์–ด
                var obj_obj = {
                    soccer: "์ถ•๊ตฌ๋ฅผ",
                    puppy: "๋ชฝ์ด๋ฅผ",
                    jw : "์ง€์›์ด๋ฅผ" //=> ์ถ”๊ฐ€
                }

                return obj_obj;
            }
        }

์ƒˆ๋กœ์šด ๋ฌธ์žฅ ์ถœ๋ ฅ ๊ฒฐ๊ณผ

์ฆ‰, ์ด์™€ ๊ฐ™์ด ์ฝ”๋“œ๋ฅผ ๊ตฌ์„ฑํ•จ์œผ๋กœ์จ ๋กœ์ง ๋‚ด ๊ฒฐํ•ฉ๋„๊ฐ€ ๋–จ์–ด์ ธ, ์žฌ์‚ฌ์šฉ๊ณผ ์œ ์ง€๋ณด์ˆ˜๊ฐ€ ์šฉ์ดํ•ด์ง‘๋‹ˆ๋‹ค.

 

์ตœ๋Œ€ํ•œ ์ฒ ํ•™์„ ๋‹ด์„ ์ˆ˜ ์žˆ๋„๋ก ์ฝ”๋“œ๋ฅผ ๊ตฌํ˜„ํ•˜์˜€์ง€๋งŒ ์•„์ง ๋งŽ์ด ๋ถ€์กฑํ•ฉ๋‹ˆ๋‹ค ใ…œใ…œ 

 

prototype์— ๊ด€ํ•ด ๊ถ๊ธˆํ•˜๋‹ค๋ฉด ์•„๋ž˜ ๋งํฌ๋กœ ๊ฐ€์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค.

 

[JS] ํ”„๋กœํ† ํƒ€์ž…๊ณผ ํ”„๋กœํ† ํƒ€์ž… ์ฒด์ธ ๊ตฌ์กฐ ์ดํ•ดํ•˜๊ธฐ

์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ๋Š” Java, Python ์ฒ˜๋Ÿผ ๊ฐ์ฒด์ง€ํ–ฅ์–ธ์–ด(Object-Oriented Programming, OOP)์ž…๋‹ˆ๋‹ค. ๊ฐ์ฒด์ง€ํ–ฅ์ด๋ž€ ํ”„๋กœ๊ทธ๋žจ์„ ๊ทธ์ € ๋ฐ์ดํ„ฐ์™€ ์ฒ˜๋ฆฌ๋ฐฉ๋ฒ•์œผ๋กœ ๋‚˜๋ˆ„๋Š”๊ฒŒ ์•„๋‹ˆ๊ณ , ํ”„๋กœ๊ทธ๋žจ์„ ๋‹ค์ˆ˜์˜ "๊ฐ์ฒด"๋กœ ๋งŒ๋“ค๊ณ ,

kingofbackend.tistory.com

 

 

profile on loading

Loading...