A simple basic introduction to JS learning

The role of JavaScript

The original purpose of JavaScript:

JavaScript was originally used to judge the basic authentication of the client to reduce the authentication pressure of the server (such as whether to enter the user name and password);

The purpose of JavaScript now:

1. The special effects of the page (the animation effect of the web page)

2. Mobile terminal development (mobile terminal web and APP)

3. Interact asynchronously with the server

4. Server development (node.js)


How browsers work

The main components of the browser include:

1. User interface - including the address bar, back/forward buttons, bookmarks directory, etc., which is what you see other than the main window used to display the page you requested

2. Browser engine - the interface used to query and operate the rendering engine

3. Rendering engine - used to display the requested content, for example, if the requested content is html, it is responsible for parsing html and css, and displaying the parsed results

4. Network - used to complete network calls, such as http requests, it has a platform-independent interface and can work on different platforms

5. UI backend - used to draw basic components such as combo selection boxes and dialog boxes, with a common interface that is not specific to a certain platform, and the bottom layer uses the user interface of the operating system

6. JS interpreter - used to interpret and execute JS code

7. Data storage - belongs to the persistence layer. The browser needs to save various data similar to cookies in the hard disk. HTML5 defines the web database technology, which is a lightweight and complete client-side storage technology.


Reference blog post: https://www.2cto.com/kf/201202/118111.html

A brief introduction to JavaScript

1. JavaScript is the most used scripting language in the world

——Scripting language: a language that does not need to be compiled and is executed while parsing at runtime

2. JavaScript is a client-side scripting language

3.JavaScript consists of three parts: ECMAscript, DOM, and BOM

- ECMAscript: JavaScript syntax specification

- DOM: JavaScript API for manipulating elements on web pages

——BOM: JavaScript API for manipulating some functions of the browser

Introduction to JavaScript tags

1.html页面添加JavaScript的两种方式

1)直接在页面书写

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>index</title>
    <script type="text/javascript">
        var n1 = 50;
        var n2 = 60;
    </script>
</head>
2)以文件形式从外部引用    好处:代码分离,方便维护

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>index</title>
    <script type="text/javascript" src="main.js"></script>
</head>


2.JavaScript加载时的两种异步属性
1)async:浏览器一边渲染一边异步加载,加载完后异步执行(sync:同步加载,默认同步)

<script type="text/javascript" src="main.js" async="async"></script>
2)defer:浏览器渲染完页面以后再执行

<script type="text/javascript" src="main.js" defer="defer"></script>



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324822765&siteId=291194637