Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the use of the init() usage in JavaScript?

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

like image 727
David S. Avatar asked Oct 25 '11 02:10

David S.


People also ask

What is init function in jQuery?

Next the jQuery() function is called, passing in a function name ( init ). This causes the init() function to run as soon as the page's DOM is loaded: $( init ); The init() function itself uses jQuery to fade all h1 headings in the Web page out, then in.

What is init function in PHP?

The init / mysqli_init() function initializes MySQLi and returns an object to use with the mysqli_real_connect() function.

What is init function in C++?

You explicitly initialize a class object when you create that object. There are two ways to initialize a class object: Using a parenthesized expression list. The compiler calls the constructor of the class using this list as the constructor's argument list. Using a single initialization value and the = operator.

What is void init in C?

void init(void) which is the start of the definition of the function. In this instance the call to init() does this: Rich (BB code):


Video Answer


1 Answers

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.

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.

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(); 
like image 182
nnnnnn Avatar answered Sep 17 '22 06:09

nnnnnn