문제

With FileUtils, do we have to use the the new word before it?

var f = new FileUtils.File(mypath);

Can't we just do:

var f = FileUtils.File(mypath);
도움이 되었습니까?

해결책

With the current Firefox version you can simply call FileUtils.File() as a function and you will get the same result. However, this is an implementation detail - the documentation clearly says that FileUtils.File() is a constructor and should be used as such, with the new keyword. So while you can use it as a function, you cannot really rely on this behavior - it might stop working if the implementation changes in future. More importantly, logically this is a constructor that creates a new object, using it as such makes the code easier to understand.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top