admin 管理员组文章数量: 1086019
Hello to whoever can help
Please refer to the code below. I just want to understand what do @private, @public, @class, and @param mean in JavaScript. Do they do anything in JavaScript or they are just there as indications to tell programmer they are what they are?
/**
* Event functions references.
* @private
*/
e = {
_onDragStart: null,
_onDragMove: null,
_onDragEnd: null,
_transitionEnd: null,
_resizer: null,
_responsiveCall: null,
_goToLoop: null,
_checkVisibile: null
};
/**
* Creates a carousel.
* @class The Owl Carousel.
* @public
* @param {HTMLElement|jQuery} element - The element to create the carousel for.
* @param {Object} [options] - The options
*/
function Owl(element, options) {
/**
* Current settings for the carousel.
* @public
*/
this.settings = null;
Hello to whoever can help
Please refer to the code below. I just want to understand what do @private, @public, @class, and @param mean in JavaScript. Do they do anything in JavaScript or they are just there as indications to tell programmer they are what they are?
/**
* Event functions references.
* @private
*/
e = {
_onDragStart: null,
_onDragMove: null,
_onDragEnd: null,
_transitionEnd: null,
_resizer: null,
_responsiveCall: null,
_goToLoop: null,
_checkVisibile: null
};
/**
* Creates a carousel.
* @class The Owl Carousel.
* @public
* @param {HTMLElement|jQuery} element - The element to create the carousel for.
* @param {Object} [options] - The options
*/
function Owl(element, options) {
/**
* Current settings for the carousel.
* @public
*/
this.settings = null;
Share
Improve this question
edited Feb 13, 2018 at 4:32
Bing Li
asked Feb 13, 2018 at 4:30
Bing LiBing Li
5091 gold badge6 silver badges11 bronze badges
2
- 8 They’re JSDoc annotations. No actual effect. – Ry- ♦ Commented Feb 13, 2018 at 4:33
- 1 Refer this. github.com/google/closure-compiler/wiki/… – syam Commented Feb 13, 2018 at 4:34
2 Answers
Reset to default 37These are known as Tags in Javascript. They are used for documentation. You have rightly guessed that they help programmers to understand the code better. Let us take one by one from the above example.
The @private tag marks a symbol as private, or not meant for general use.
So, variable e is supposed to be private and shouldn't be accessed outside the current class.
The @class tag marks a function as being a constructor, meant to be called with the new keyword to return an instance.
So here it says that function Owl is a constructor function and should be called with a new keyword while being invoked.
The @public opposed to @private suggests that the function is publicly available to be accessed outside the current context.
Hence, owl function can be called outside the current class.
The @param describe the parameters of the function. There are three parts of it. First is within {}. It suggests the type of the param. Second is name of the param. Third is after they hyphen(-) sign. It describes the parameter.
So, we have two parameters here. First is of HTMLElement or jQuery type, named element which has description : The element to create the carousel for. Second is of Object type named options with description : The options.
Hope this helps. You can read more about tags here under Block Tags.
Those are in comments, the JS interpreter won’t even read them. They are comments for the developer and possibly can be used by an auto documentation tool or IDE for syntax help.
本文标签: javascriptwhat do private public class and param mean in JSStack Overflow
版权声明:本文标题:javascript - what do @private, @public, @class and @param mean in JS - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/p/1737451802a1831464.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论