Does jQuery or JavaScript have the concept of classes and objects?

前端 未结 7 1170
故里飘歌
故里飘歌 2021-01-30 00:28

I found the following code somewhere, but I am not understanding the code properly.

ArticleVote.submitVote(\'no\');return false;

Is Arti

7条回答
  •  灰色年华
    2021-01-30 00:50

    You can use the JavaScript function as class.

    ClassUtil = function(param){    
         privateFunction = function(param){    
            // Do some thing    
            return valueParam;
        }    
        this.publicFunction = function(){    
            var val1 = function1();    
            if (val1){    
                return true;    
            } else{    
                return false;
            }
        }
    }
    
    function getClass(){    
       var classUtil = new ClassUtil();     
       alert(classUtil.publicFunction());    
    }
    

    There is one public and one private function. You can call public function from out side using object of the class.

提交回复
热议问题