Es6 Let Const

1. Block-level scope

ES5 only has global scope and function scope, but no block-level scope.

Variables declared outside the function are global variables, which can easily lead to variable conflicts. Therefore, we have to use execute function immediately to avoid conflicts with global variables. In addition, variables used for counting within the loop will also be leaked into global variables.

To this end, ES6 introduces the concept of block-level scope.

Js Array

Method without changing the original array:

  1. indexOf() and lastIndexOf()

  2. 1 indexOf(): Returns the index of the element in the array, starting from 0. If the element does not exist in the array, -1 is returned.

	var arr = [1, 2];
	arr.indexOf(1); //0
	arr.indexOf(10); //-1
  1. 2 lastIndexOf(): Returns the index of the last occurrence of an element in the array, or -1 if it does not appear.
	var arr = [1, 2, 3, 4, 2];
	arr.lastIndexOf(2); // 4
  1. slice(): Like the substring() method of string, it intercepts a part of the array and returns a new array.

Throw Away Vocabulary Book

Vocabulary is all saved

In fact, the essence of language learning is the same. Let’s first review the process of learning Chinese (Mandarin). In the process of learning Chinese, how many people have encountered Chinese teachers or parents who asked them to recite “Xinhua Dictionary” and “Cihai”? I think most people should not have this experience.

Most of us have gradually accumulated Chinese vocabulary through studying day after day. In fact, by the middle school stage, after we have mastered the 3,500 commonly used Chinese characters, there is basically no obstacle to reading Chinese. You may have encountered some unfamiliar words or phrases, such as “peers” and “ghosts and monsters”. At this point, you might stop and look it up in a dictionary to see how it is pronounced and what it means. If this word is a polyphonic word, you may also pay attention to the pronunciation of this word.

Copy2clipboard

1.ZeroClipboard.js

Click a button to copy a link or a piece of text to the clipboard. Many people must have seen this small function. There is such a function on GitHub that can copy the warehouse address with the click of a button. As shown below:

Github uses ZeroClipboard to implement this function. This library uses an invisible Flash to complete the cut and paste operation. That is to say, Flash is made transparent so that we can place it wherever we need to place it, such as links, buttons, etc. In this way, the user interface looks unchanged, and when a link or button is clicked, the click is actually Flash, thus achieving a copy operation. For specific implementation methods, please refer to the official documentation http://zeroclipboard.org.

Useragent

The websites of many Internet companies are divided into PC and mobile terminals. If a user uses a mobile phone to access a PC site, the web page may be loaded slowly due to the limitations of the mobile phone network. Therefore, how to identify the device used by users to access the website and automatically jump to the corresponding site?

Navigator is an independent object in JavaScript, used to provide information such as the browser and operating system used by the user, in the form of navigator object attributes. This object is supported by all browsers.

Anywhere

How to test static files on mobile devices?

Now that mobile is given priority, after front-end engineers write static pages, they usually need to test the effects on different devices to see if there are any compatibility issues. Google Chrome has a debugging function that simulates a mobile phone. Generally, we use Google to debug it first. But after all, it is a simulation. To be on the safe side, it still needs to be tested with a real machine.

Everybody Can Speak English

1. Why learn English?

1.1 Is it really necessary to learn English?

For students, English is a compulsory course and must be learned. For office workers, some people learn English because of work needs, such as employees of foreign companies, foreign tour guides, and foreign trade practitioners; some people learn English out of hobbies, such as watching original British and American movies, listening to English songs, and even reading English novels.

Hugo

Recently, I had a sudden impulse to start my blog again. So, I found that Hugo is more useful than the Jekyll I used before. This article is a personal record of building a personal blog with reference to Hugo official website.

Step 1. Install Hugo Download and install Hugo

Download address: https://github.com/spf13/hugo/releases. According to your operating system, download the corresponding installation package. My operating system is Win7 64bit, and I selected hugo_0.19_Windows-64bit.zip.

Inline Bug

1. inline element:

If the code of inline elements (span, strong, b, em, i, etc.) is wrapped, there will be an undesirable gap between them. By setting margin:0 or padding:0, this gap still exists, indicating that this gap is not margin or padding.

In order not to eliminate this gap, do we have to write the html code of the inline element in one line? The answer is no. During development, in order to facilitate reading and debugging, we are accustomed to writing the code like this:

Js Reg

1.Basic concepts

A regular expression (Regular Expression) is a string that defines a rule according to which a series of strings that meet conditions are described and matched.

2. Wildcard

Find files in the current directory (linux command line)

find ./ -name *.txt

3. Online graphics tools:

https://regexper.com/ is a very practical regular expression graphical tool. You can also download to your local computer to run faster

4. Regular expressions can be supported in IDE:

The editor I use is Sublime Text 3. Use the shortcut key Ctrl+F to search for a string, Ctrl+H to replace a string, and open regular expressions in the upper left corner of the panel called up at the bottom (shortcut key Alt+R)