Author: Mr. Liu Shangyuan
- Give no less than any effort
- May all our efforts be lived up to
- Never forget why you started, and your mission can be accomplished.
Learn from the beginning to the end
You've heard the story of a bear breaking a stick
They think bear is stupid
I don't think I'll ever do that
But they often do things like that
But I don't think
Like programming learning
After learning the front end, I heard that Python was very popular
I'm going to learn Python again,
Then I heard that the go language is very popular
Endless loss of watermelon and sesame
I've been learning, but I haven't learned one well
How similar are you to a bear!!!
<!DOCTYPE html> <!-- Document type: Standard html File --> <html lang='en'> <!-- html Root tag translation text: English --> <head> <!-- Webpage header --> <meat charset='UTF-8'/> <!-- Web page character encoding --> <meat name='Keywords' content='Keywords 1,Keywords 2'/> <meat name='Description' content='Website description'/> <meat name='Author' content='author'/> <title>Front end 59 student assignments</title> <!-- Webpage title --> <link rel='stylesheet' type='text/css' href='css/css1.css'/> <!-- Chain style sheet --> <style type='text/css'> /*Internal style sheet*/ </style> </head> <body> <!-- Web backbone: visualization area --> <div class='box'></div> <script> // this function () { console.log(this); } let obj = { a: fn } fn(); // this refers to the top-level object when the function does not depend on any object obj.a(); // this points to the object obj on which the function depends document.onclick = fn; // this points to document box.onclick = fn; // this points to box // Function key: arguments class array function fn() { console.log(arguments); // Use when the number of real parameters is uncertain console.log(arguments.length); // Number of arguments console.log(arguments[0]); // Subscript location } fn(1, 2, 3, 4); fn(1); // rest parameter let fn(a, ...b) { // ... b must be last console.log(a); // rest can have parameters at the same time, a = 1 console.log(b); // b is an array, b = [2, 3, 4] [] } fn(1, 2, 3, 4); fn(1); // Arrow function let add1 = function (n) { return n + 1; } add1(5); let add2 = (n) => n + 1; // Equivalent to a value of return within the function add2(5); let add3 = function (n) { let a = n * 2; let b = a + 2; return b; } add3(5) let add4 = (n) => { let a = n * 2; let b = a + 2; return b; // Arrow function complex writing } add4(5); // this of arrow function let add5 = (n) => { console.log(this); // Arrow function does not have this. It points to the outer object by default } // arguments of arrow function let add6 = (n) => { console.log(arguments); // Arrow function has no arguments } // Strict mode: 'use strict' // Function name function fn(a, b, c, d, e = 1, ...f) {} fn(1, 2, 3); console.log(fn.name); // Function name, fn console.log(fn.length); // The length of the function returns the number of parameters. The default parameter and rest do not count. 4 // iife execute function expression immediately // You can change a global variable into a local variable // Will not pollute the overall environment // iife function name cannot be called // es5: (function (){ let a = 1; var b = 1; })(); // es6: { let a = 1; var b = 1; } // The difference between function expression and function declaration: function expression can be executed immediately by adding () directly let fn = function () { console.log('1'); }(); // The first way to write (function (){})(); // The second way of writing (function (){}()); // The third way of writing !function (){}(); // The fourth way of writing ~function (){}(); // The fifth way of writing +function (){}(); // The sixth way of writing -function (){}(); </script> </body> </html>