javascript - var functionName = function() {} vs function functionName() {}

Опубликовано: 19 Март 2024
на канале: Code Samples
14
0

I've recently started maintaining someone else's JavaScript code. I'm fixing bugs, adding features and also trying to tidy up the code and make it more consistent.
The previous developer used two ways of declaring functions and I can't work out if there is a reason behind it or not.
The two ways are:
var functionOne = function() {
// Some code
};

And,
function functionTwo() {
// Some code
}

What are the reasons for using these two different methods and what are the pros and cons of each? Is there anything that can be done with one method that can't be done with the other?
hoisting: http://adripofjavascript.com/blog/dri...
Strict mode: https://udn.realityripple.com/docs/Gl...


Смотрите видео javascript - var functionName = function() {} vs function functionName() {} онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Code Samples 19 Март 2024, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 14 раз и оно понравилось 0 людям.