+ 1

Is init() a javascript function?

I always see many codes using this, and If it's a function, what is It for?

21st Jun 2017, 5:47 PM
Gelson Antunes
Gelson Antunes - avatar
2 ответов
+ 2
I can't find any manuals on this, are you sure it's not just a function called 'init' that the person created? So what it does depends on what's in the functions block. I don't code in Javascript much at all, but I'm assuming it could be a common practice to call something init() when all it does is initialize variables. For another common practice naming example you can look at the for loop: for(var i = 0; i < 10; i++) {} You'll likely see 'i' a lot. That's just the name of the variable, much like how I assume init() is just the name of the function. If you see 'init();' Then that's calling the function called init.
21st Jun 2017, 6:07 PM
Rrestoring faith
Rrestoring faith - avatar
0
The init function that you're seeing is not a part of the JavaScript language, but either a part of the individual programmers code as @Rrestoring faith stated, or possibly part of a framework or library. JavaScript by itself doesn't have a built in function called init().
21st Jun 2017, 8:52 PM
ChaoticDawg
ChaoticDawg - avatar