Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the two fast writing methods of console.log in vscode?

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

Today, I will talk to you about what the two fast writing methods of console.log in vscode are, which many people may not know. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.

(1) method 1: define directly in advance in the script tag, which is only applicable to the html file!

Let add = function (function) {return a + b;}; console.log (add (20300)); const {['log']: C} = console; C (add (20300))

(2) method 2: press the tab key to quickly generate console.log, and the cursor is inside (), press the tab key cursor again to automatically jump to the next line!

1. Open the vscode editor, select File-> preferences-> user section, enter javascript.json and press enter to enter.

When we use it for the first time, we will find a piece of annotated code as follows:

{/ / Place your snippets for javascript here. Each snippet is defined under a snippet name and has a prefix, body and / / description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are: / / $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the / / same ids are connected. / / Example: / / "Print to console": {/ / "prefix": "log", / / "body": [/ / "console.log ('$1') ", / /" $2 "/], / /" description ":" Log output to console "/ /}}

2. The interval code below removing Example is as follows, and some of the parameters are as follows:

① prefix: the entry of code shortcuts. Here we can set it according to our personal habits. For example, if I set cl, then you can generate console.log directly with tab key.

② body represents the body of the code:

$1 indicates the location where the cursor appears for the first time after the generation code is generated quickly

Write $2 under "console.log ('$1');", indicating that after quickly generating console.log (), a line will be left empty after the code, and when you press the tab key again, the cursor will jump to the position of $2 (the empty line).

{/ / Place your snippets for javascript here. Each snippet is defined under a snippet name and has a prefix, body and / / description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are: / / $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the / / same ids are connected. / / Example: "Print to console": {"prefix": "cl", "body": ["console.log ('$1') "," $2 "]," description ":" Log output to console "}} after reading the above, do you have any further understanding of the two fast writing methods of console.log in vscode? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report