javascript - Problem with !function()
曾经蜡笔没有小新
曾经蜡笔没有小新 2017-05-19 10:13:21
0
4
532

!function(){} is placed in the js file. How to call the method inside after referencing it?

曾经蜡笔没有小新
曾经蜡笔没有小新

reply all(4)
为情所困
// test.js
!function(){
  var a = function(){console.log(1)}
  this.demo = a;                                                       
}();
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<script src="test.js"></script>
</head>
<body>
<SCRIPT>
demo()                                                                 
</SCRIPT>
</body>
</html>
伊谢尔伦

Just return the internal method

我想大声告诉你

!function(){} is not a method, but an expression with a value of false.

刘奇

!function means executing the function immediately. You need to see if there are any methods open to the outside world inside the function, such as modifying the properties of the window object

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template