preface
It is quoted from JavaScript advanced programming fourth edition: “from simple input verification script to powerful programming language,JavaScript
No one predicted the rise of China’s economy. It’s very simple, it takes only a few minutes to learn to use; it’s very complex, it takes many years to master it. We should really learn to use it wellJavaScript
It is very important to understand its essence, history and limitations.
interviewer:
JavaScript
What is it?
Me: EMJavaScript
namelyJavaScript
… 👀
Imagine if the interviewer asks you:JavaScript
What is it? What would you say? To be honest, when I heard this question, my mind was blank for a moment. We’ve been learning the front end for so long, even the simplest"What is JavaScript?"
You can’t tell the interviewer why. Let’s talk about this today. When the interviewer asks youJavaScript
When is it? What points can you start from? Say as much as you can and make a good impression on the interviewer.
JavaScript
What is the positioning of the company?
1. JavaScript
It’s a scripting language
Why a scripting language? Let’s take a brief look atJavaScript
The ups and downs of the advent, in a word, Netscape company in 1995 to solve the problemCommunication delay between client and server in simple form verification
A new one calledJavaScript
At that time, Microsoft decided to invest more resources in IE and launch it specificallyJScript
And then toEcma
(European Association of computer manufacturers)ECMAScript
(pronounced “EK Ma script”) international standardizes two languages to solve the problem of two versions coexisting.
What can scripting languages do? It can achieve complex functions on the web page, including the operation of theDOM
ElementsCSS
Style, can realize interactive map,2D/3D
Animation, scrolling video, etc.JavaScript
It has a very powerful and flexible ability in the host environment, which provides more possibilities for developers.
2. JavaScript
It’s a weakly typed language
This means that a variable can be implicitly converted to another type. Type of hidden conversion, giveJavaScript
With a certain degree of flexibility, but also increases the complexity of the rules and the possibility of errors.
- Binary operator
+
Converts both operands to a string, unless both operands are numeric. that is because+
It can also be used to connect strings. - Binary operator
-
Converts two operands to numeric types. - Unary operators, including + and -, convert operands to numbers.
console.log(1 + '2' === '12')
// true
console.log('3' - '1' === 2)
// true
console.log(+'1' === 1)
// true
console.log(-'1' === -1)
// true
3. JavaScript
It’s dynamic
- Like most scripting languages, their types are associated with values, not variables. For example, a variable can be numeric and then assigned to a string.
let a = 233
A ='tantiedan '
console.log(a)
//'tantiedan '
- JavaScript statements can be executed directly at run time
eval(" console.log ('students playing iron eggs') ")
//'tantiedan '
4. JavaScript
It’s single threaded
JavaScript
Need to interact with the page, operationDOM
If it is multithreaded, it will bring a very complex synchronization problem. For example, supposeJavaScript
There are two threads at the same time, one thread in aDOM
When content is added to a node and the node is deleted by another thread, which thread should the browser follow? So it can only be single threaded,
5. JavaScript
Interpretative language
Interpreted language is a kind of programming language. This type of programming language will run the code sentence by sentence directly, and it does not need to be compiled into machine code by compiler before running, just like compiled language.
6. JavaScript
It has good cross platform performance
Cross platform features, under the support of most browsers, can run in a variety of platforms (such asWindows
、Linux
、Mac
、Android
、iOS
Etc.).
JavaScript
andECMAScript
What’s the difference between, and betweenDOM
、BOM
What’s the relationship?
First, a brief summaryECMAScript
、 DOM
、BOM
Three concepts.
DOM
DOM
(document object model), which provides a way to interact with web contentmethod
andInterface
。 DOM
The whole page is abstracted as a group of hierarchical nodes.HTML
orXML
Each component of a page is a node that contains different data.DOM
By creating a tree representing documents, developers can control the content and structure of web pages at will. useDOM API
It can easily delete, add, replace and modify nodes.
<html>
<head>
<title>Sample Page</title>
</head>
<body>
<p> Hello World!</p>
</body>
</html>
BOM
BOM
(browser object model), which provides the interface for interaction with browsermethod
andInterface
。 BOM
Mainly for browser window and sub window (frame). useBOM
, developers can control the browser to display parts outside the page, such as:
1) Ability to pop up new browser windows;
2) Ability to move, zoom and close browser windows;
3)navigator
Object to provide detailed information about the browser;
4)location
Object, which provides the detailed information of the browser loading page;
5)screen
Object to provide detailed information about the resolution of the user’s screen;
6)performance
Object, which provides detailed information of browser memory usage, navigation behavior and time statistics;
7) For browser storage related operations, such ascookies
、sessionStorage
、localStorage
Etc;
8) Other custom objects, such asXMLHttpRequest
andIE
OfActiveXObject
;
ECMAScript
ECMAScript
This paper describes the syntax and basic objects of javascript: 1) syntax; 2) type; 3) statement; 4) keyword; 5) reserved word; 6) operator; 7) global object; 4) object;
ECMA
release262
The first edition of ecma-262 specifies the standard of browser script language, which is called “browser script language”ECMAScript
This version is1.0
So the one sentence description is,ECMAScript
It’s a set of norms,JavaScript
then isECMAScript
An implementation. Why is it an implementationAdobe ActionScript
The same is trueECMAScript
,JScript
The same is trueECMAScript
。
[
ES
[version related]
relationship
So after a brief understanding of the above key concepts, we can easily get the relationship between them! There is such a picture in “JavaScript advanced programming fourth edition”, which willJavaScript
、ECMAScript
、 DOM
、BOM
The relationship between the four is very clear.
We come to the conclusion that ECMAScript, DOM and BOM are components of JavaScript.
summary
So at the end of the article, when the interviewer asks, “what is JavaScript,” we know where to start and where to start. So if we make the main points of this article clear to the interviewer, I believe we can leave a not too bad impression on the interviewer
-
JavaScript
The positioning ofJavaScript
It’s a scripting languageJavaScript
It’s a weakly typed languageJavaScript
It’s dynamicJavaScript
It’s single threadedJavaScript
Interpretative languageJavaScript
It has good cross platform performance
-
JavaScript
andECMAScript
The difference between, andDOM
、BOM
The relationship betweenDOM
(document object model), which provides a way to interact with web contentmethod
andInterface
BOM
(browser object model), which provides the interface for interaction with browsermethod
andInterface
ECMAScript
DescribedJavaScript
Grammar and basic objects of
Finally, I’d like to quote the opening paragraph, “it’s very important to understand the essence, history and limitations of JavaScript in order to really learn and use JavaScript well.”~
- For more interesting and interesting articles, please pay attention to the official account.
Front end iron egg
“Yes - GitHub original