JavaScript中init()用法的用途是什么? [英] What is the use of the init() usage in JavaScript?

查看:669
本文介绍了JavaScript中init()用法的用途是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JavaScript中init()函数的含义和用法是什么?

What is the meaning and usage of the init() function in JavaScript?

推荐答案

JavaScript没有内置的init()函数,也就是说,它不是该语言的一部分.但是,对于单个程序员来说,创建自己的init()函数来进行初始化工作并不少见(在许多语言中).

JavaScript doesn't have a built-in init() function, that is, it's not a part of the language. But it's not uncommon (in a lot of languages) for individual programmers to create their own init() function for initialisation stuff.

特定的init()函数可用于初始化整个网页,在这种情况下,它可能会从document.ready或onload处理中调用,或者可能是初始化特定类型的对象,或者...好吧,你命名.

A particular init() function may be used to initialise the whole webpage, in which case it would probably be called from document.ready or onload processing, or it may be to initialise a particular type of object, or...well, you name it.

任何给定的init()具体做什么实际上取决于编写它的人需要它做什么.某些类型的代码不需要任何初始化.

What any given init() does specifically is really up to whatever the person who wrote it needed it to do. Some types of code don't need any initialisation.

function init() {
  // initialisation stuff here
}

// elsewhere in code
init();

这篇关于JavaScript中init()用法的用途是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆