|
@@ -0,0 +1,24 @@
|
|
|
+<!DOCTYPE html>
|
|
|
+<html lang="en">
|
|
|
+<head>
|
|
|
+ <meta charset="UTF-8">
|
|
|
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
|
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
+ <title>Document</title>
|
|
|
+</head>
|
|
|
+<body>
|
|
|
+ <script src="./src/apply.js"></script>
|
|
|
+ <script>
|
|
|
+ function add (a,b){
|
|
|
+ console.log(this)
|
|
|
+ return a + b + this.c
|
|
|
+ }
|
|
|
+ let obj = {
|
|
|
+ c: 5
|
|
|
+ }
|
|
|
+ window.c = 6
|
|
|
+ console.log(apply(add,obj,[1,2]))
|
|
|
+ console.log(apply(add,null,[1,2]))
|
|
|
+ </script>
|
|
|
+</body>
|
|
|
+</html>
|