Home  >  Article  >  Backend Development  >  Another way to write js to share

Another way to write js to share

小云云
小云云Original
2018-03-31 09:11:281370browse

This article mainly shares with you another way to write js, a way to prevent duplication of method names. It mainly explains it to you with a piece of code. I hope it can help you.

 var mytest = function() {
    
    return {
        
        test1:function () {
            
            alert("this is a test1 func");
        }
        
        test2: function () {
            
            alert("this is a second func");
        }
    };
}();

Use mytest.test1() when calling

The above is the detailed content of Another way to write js to share. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn