search
HomeWeb Front-endJS TutorialEasy-to-understand JavaScript introduction

This article brings you relevant knowledge about javascript, which mainly sorts out the related issues introduced. Javascript is a prototype developed from Netscape's LiveScript. Inherited object-oriented dynamic type case-sensitive client scripting language, let's take a look at it together, I hope it will be helpful to everyone.

Easy-to-understand JavaScript introduction

[Related recommendations: javascript video tutorial, web front-end

1. Introduction to JS

Javascript is a prototype-inherited, object-oriented, dynamically typed, case-sensitive client scripting language developed from Netscape’s LiveScript. Its main purpose is to solve Server-side languages, such as Perl, have legacy speed issues and provide customers with smoother browsing.

# ## At that time, the server needed to verify the data. Since the network speed was very slow, only 28.8kbps, the verification step wasted too much time. So Netscape's browser Navigator added Javascript to provide basic functions of data verification. The official name of JavaScript is "ECMAScript". This standard is developed and maintained by the ECMA organization. ECMA-262 is the official JavaScript standard. This standard is based on JavaScript (Netscape) and JScript (Microsoft).

 Brendan Eich of Netscape (Navigator 2.0) invented this language, which has appeared in all Netscape and Microsoft browsers since 1996. Development of ECMA-262 began in 1996, and in July 1997, the ECMA General Assembly adopted its first version.

The components of JavaScript include

ECMAScript, DOM, BOM.

JS is a small script statement that runs on the browser side, which can realize web page text content animation, dynamic data changes, animation special effects, etc.


Easy-to-understand JavaScript introduction
ECMAScript

is a scripting language standardized by the European Computer Manufacturers Association (ECMA) through ECMA-262. To put it simply, ECMAScript describes It covers syntax, types, statements, keywords, reserved words, operators and objects. It defines all the properties, methods and objects of the scripting language.

DOM

Plan the entire page into a document composed of node layers. It is not related to the browser, platform, or language, and provides a standard for web developers. Access data, scripts and presentation layer objects in the site. DOM programming can achieve the effect of web page content verification and dynamic changes

BOM

is a type of browser Features, it can access and operate the browser window, such as moving, closing the window, adjusting the window size, supporting cookies, etc. BOM programming can achieve the effect of dynamically controlling the behavior of the browser itself

Some people also say this:

ECMAScript can be understood as the basic syntax part of JS

DOM can be simply understood as using the document object Programming to operate the document content

BOM can be understood as programming to use the window object to operate the browser behavior

2. JS Features

JS Features

JS is a scripting language that runs on the browser

1.
Scripting language

Scripting language is a simple program that is small in scale and does not require It compiles, runs quickly, is composed of some ASCII characters, and can be written using any text editor. Scripting language refers to a programming language that is interpreted and executed by an interpreter in a web browser. Every time a program is run, the interpreter will translate the program code into an executable format. Some programming languages ​​(such as C, C, Java, etc.) must be compiled, and the source code must be compiled into a binary executable file before it can be run. Scripting languages ​​do not need to be compiled in advance, as long as there is a suitable interpreter. implement.

2.

Object-based language

Object-oriented has three major characteristics (encapsulation, inheritance, polymorphism) that are indispensable. Usually "object-based" uses objects, but existing object templates cannot be used to generate new object types. In other words, "object-based" does not have the characteristics of inheritance. Without the concept of inheritance, there is no way to talk about "polymorphism"

3.

Event-driven

The action that performs a certain operation on a web page is called " "Event" (Event), such as pressing the mouse, moving the window, selecting the menu, etc. can be regarded as events. When an event occurs, a corresponding event response may be triggered.

4.

Simplicity

The variable type is weakly typed and does not use strict data types.

var a,b,c; a=123; b="abc"; a=b;

5.

Security

JavaScript It cannot access the local hard disk, cannot store data on the server, cannot modify or delete network documents, and can only achieve information browsing or dynamic interaction through the browser

6.

Cross-platform

JavaScript depends on the browser itself and has nothing to do with the operating platform. As long as the computer has a browser that supports JavaScript (installed with a JavaScript interpreter), the JavaScript program can be executed correctly.

Disadvantages:

Various browsers support JavaScript to varying degrees. Browsers that support and do not fully support JavaScript are browsing the same JavaScript script. There will be a certain gap in the effect of the web page, and sometimes it will not even be displayed.

3. The difference between JS and Java

Difference 1: Different companies, different predecessors

JavaScript is a product of Netscape Company and is used to extend Netscape An object-based and event-driven interpreted language developed for the Navigator function that can be embedded in Web pages. Its predecessor is Live Script; Java is a new generation of object-oriented programming language launched by SUN, which is particularly suitable for Internet applications. Program development; Java's predecessor is the Oak language.

Difference 2: Object-based and object-oriented

JavaScript is a scripting language and an object-based language. It itself provides a very rich set of internal objects for designers to use, but does not support inheritance and polymorphism. Java is object-oriented, a true object-oriented language, supporting encapsulation, inheritance and polymorphism.

Difference 3:Variable types are different in strength and weakness

Java uses strong type variable checking, that is, all variables must be declared as a specified type before compilation. For example: int x=1234; is a weakly typed variable in JavaScript. The var statement is uniformly used and various data type values ​​can be assigned.

Difference 4: The running location is different

Java runs on the server side, a large programming language, JS runs on the client (browser), a small-scale scripting language

4. The relationship between HTML, CSS and JS

HTML, CSS and JS are the main front-end technologies, and each of the three has its own division of labor. HTML can be used to make the main body of a web page Structure, CSS is used to beautify the web page, and JS is used to add dynamic effects to the web page. How about

Easy-to-understand JavaScript introduction, how about the image, my friend.

5. How to introduce JS

1. Embedded

Inline introduction method:

1. In the head tag, use a For the script tag, embed the js code

2.type attribute does not need to be written

nbsp;html>
	
		<meta>
		<title>js引入方式1</title>
		<!--内嵌式引入方式
			1.在head标签中,用一对script标签,嵌入js代码
			2.type属性可以不写
		-->
		<script>
			
		//定义一个函数(方法)
		function fun1 () {
			//弹窗提示信息
			alert("hello word")
		}
		</script>
	
	
		<input>
	

Easy-to-understand JavaScript introduction

Disadvantages:
1 We define The JS code can only be used in the current web page, with low code reuse and low maintainability

2 The JS code and HTML code are mixed in one file, and the readability is poor

2 Linked

Easy-to-understand JavaScript introduction

nbsp;html>
	
		<meta>
		<title>js引入方式2</title>
		<!--链接式引入外部js文件
			1.提高代码复用度
			2.降低代码的维护难度
			3.一个页面可以同时引入多个不同的js文件
			4.script标签中一旦引入外部结束文件,就不能在中间定义内嵌代码
		-->
		<script></script>
		<script></script>
		<script>
			function fun3() {
				alert("js引入方式")
			}
		</script>
	
	
		<input>
		<input>
		<input>
	

Advantages:

High code reuse, easier to maintain code

Note:

1 Multiple JS files can be introduced on one page at the same time

2 Each JS file must be introduced using an independent scripttag

3 The same tag cannot be used for inline and link introductions

[Related recommendations: javascript video tutorial, web front-end

The above is the detailed content of Easy-to-understand JavaScript introduction. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:CSDN. If there is any infringement, please contact admin@php.cn delete
es6数组怎么去掉重复并且重新排序es6数组怎么去掉重复并且重新排序May 05, 2022 pm 07:08 PM

去掉重复并排序的方法:1、使用“Array.from(new Set(arr))”或者“[…new Set(arr)]”语句,去掉数组中的重复元素,返回去重后的新数组;2、利用sort()对去重数组进行排序,语法“去重数组.sort()”。

JavaScript的Symbol类型、隐藏属性及全局注册表详解JavaScript的Symbol类型、隐藏属性及全局注册表详解Jun 02, 2022 am 11:50 AM

本篇文章给大家带来了关于JavaScript的相关知识,其中主要介绍了关于Symbol类型、隐藏属性及全局注册表的相关问题,包括了Symbol类型的描述、Symbol不会隐式转字符串等问题,下面一起来看一下,希望对大家有帮助。

原来利用纯CSS也能实现文字轮播与图片轮播!原来利用纯CSS也能实现文字轮播与图片轮播!Jun 10, 2022 pm 01:00 PM

怎么制作文字轮播与图片轮播?大家第一想到的是不是利用js,其实利用纯CSS也能实现文字轮播与图片轮播,下面来看看实现方法,希望对大家有所帮助!

JavaScript对象的构造函数和new操作符(实例详解)JavaScript对象的构造函数和new操作符(实例详解)May 10, 2022 pm 06:16 PM

本篇文章给大家带来了关于JavaScript的相关知识,其中主要介绍了关于对象的构造函数和new操作符,构造函数是所有对象的成员方法中,最早被调用的那个,下面一起来看一下吧,希望对大家有帮助。

JavaScript面向对象详细解析之属性描述符JavaScript面向对象详细解析之属性描述符May 27, 2022 pm 05:29 PM

本篇文章给大家带来了关于JavaScript的相关知识,其中主要介绍了关于面向对象的相关问题,包括了属性描述符、数据描述符、存取描述符等等内容,下面一起来看一下,希望对大家有帮助。

javascript怎么移除元素点击事件javascript怎么移除元素点击事件Apr 11, 2022 pm 04:51 PM

方法:1、利用“点击元素对象.unbind("click");”方法,该方法可以移除被选元素的事件处理程序;2、利用“点击元素对象.off("click");”方法,该方法可以移除通过on()方法添加的事件处理程序。

整理总结JavaScript常见的BOM操作整理总结JavaScript常见的BOM操作Jun 01, 2022 am 11:43 AM

本篇文章给大家带来了关于JavaScript的相关知识,其中主要介绍了关于BOM操作的相关问题,包括了window对象的常见事件、JavaScript执行机制等等相关内容,下面一起来看一下,希望对大家有帮助。

foreach是es6里的吗foreach是es6里的吗May 05, 2022 pm 05:59 PM

foreach不是es6的方法。foreach是es3中一个遍历数组的方法,可以调用数组的每个元素,并将元素传给回调函数进行处理,语法“array.forEach(function(当前元素,索引,数组){...})”;该方法不处理空数组。

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)