


Get out of the JavaScript beginner's dilemma—js beginner_basic knowledge
从开始接触JS这东西有一年时间了,心头总是有一些说不出来的苦闷。在论坛里也常常有人这么说。那么苦在何处呢?总是感觉学的不深入,一些简单的东西可以做但也是不能得心应手。能不能把这种苦再说的具体点儿呢?都说了是“说不出来的苦闷”怎么具体呀?
何为难言之隐?说不出来,不能具体,不能把问题落到实处就不能得到解决的办法。这就是难言之隐!我认为这也就是初学者的“困境”。之所以要用“我认为”正好迎合了本文标题中的“心得”二字。如果能对大家有帮助我非常高兴。
下面言归正传,我经过回想和思考总结出下面几条初学者的“难言之隐”大家看看有没有说到我们的心坎儿上,呵呵。
一、用系统的知识将问题具体化
我们在学习时经常会发现可以用不同的方法来实现同一个问题。例如,要为元素绑定一个点击事件可以在HTML元素上用,我们起初会认为这就是绑定事件的方法。
当我们第二次又看到可以将一个函数传递给一个事件来绑定:a.onclick=f1;这时我们又会想原来绑定事件不只有一种方法。
当我们第三次又看到用addachEvent("onclick",f1)这种方法绑定事件的时候,你一定会想绑定事件的方法可能不只这三种。而且做一件事没理由要三种相同的方法,他们之间一定有不同之处?
那么他们有什么不同之处呢?到底绑定事件有多少种方法呢?当你发现一种方法在IE中不兼容的时候你还会问这到底是为什么呢?是我的语法错误了吗?还是怎么回事。一个又一个的问题结束之后你只好问自己:“天呀!我什么时候才能学好JavaScript呢?!“。
可能这样下去你很难学好JS。其实还要告诉你,你离学好他并不远了,只是你不知道怎么走。原因在哪里?原因就是没有系统的知识,原因就是没有读过《JavaScript权威指南》,他会告诉你绑定事件有四种方法,并且有两种是基本方法,所有浏览器都支持他,另外还有两种高级方法,一种是W3C标准方法,一种是IE标准方法,所以你知道为什么IE不兼容其中的一种高级方法了,对吗?
现在事情具体化了,绑定一个事件的时候只需考虑这四种方法,你也不会再有那么多的疑惑了。你也会觉得自己弄懂事件了,下一步你应该去弄懂其它问题了,你还会觉得自己在JS方面终于有进展了,当然你还会感觉到走出一个困境了。
二、必需了解JavaScript的历史
你了解JS的历史吗?我当然了解,他原本不叫JavaScript,他最早不是实现在IE中的。对,说的很好,可这不是最重要的,知道这个也不会成为高手,你必须了解的更详细,而且主要是了解功能进化方面的历史。
就像上面,为什么绑定事件会有那多的方法?为什么获得一个元素会有那么多的方法?倒底是document.links[]正规一点?还是getElementsByTagName('a')正规一点?哪一个兼容性更好?还有多少这样的方法?
要知道一个问题就够头痛了,十个问题你就无从下手,一百个问题你就会怀疑自己。一千个问题最后又回到那个问题“天呀!我什么时候才能学好JavaScript“?呵呵,事情往往就是这样。解决的方法就是具体化他,去弄懂到底有几种方法,为什么又有这些方法。这些问题一定会有答案,因为JS不是外星人留下的东西,是人创造出来的,而那个人的思维也是有限的,不是吗?
当你知道document.links[]是遗留的document方法,而且这种遗留方法一共有5个。分别是anchors[],applets[],forms[],images[],links[]的时候有些问题就消失了,当你还知道DOM标准保留了他们,你还知道所有浏览器都支持他们,你还知道他们就是所谓的“0级DOM”你又会走出一个“困境”。
三、JS有纵横交错的知识结构
JS的知识结构是横向和纵向交错的,这加大了理解他的难度,对这一点必需有一个清晰的认识。下面解释一下“纵横交错”。
一般的知识都有横向性。比如从大的方面JS分为核心部分和客户端部分。这是横向。核心部分又分为词法结构,数据类型和值,变量,表达式和运算符,语句,对象和数组,函数,类,模块和名字空间,正则表达式。这也是横向。
客户端部分可以分为BOM,DOM,事件,样式,表单等,这些也是横向的知识结构。
A technology rarely uses time as a structure, but because the development of browsers is dynamic, browsers in different periods have different levels of implementation of JS, and web pages written for the browsers at that time at different times cannot be changed because of The development of technology should not be taken into consideration, and it is impossible for all websites to be rewritten with the development of technology. Therefore, JS must be developed and upgraded while retaining forward support. So even if there is a better method, the previous method must be retained. There are many legacy JS properties and methods. For example, the "level 0 DOM" has been retained in the new W3CDOM. To a certain extent, it is vertical of.
When I have a clear understanding of the knowledge structure, one benefit is that when I want to solve a problem, I can know which piece of knowledge I want to use. For example, if you want to get the position of an element in the document, you will know to use the attributes of the element in the DOM. If you want to get the position of the mouse pointer, you will use the attributes of the event object. To obtain a reference to an element, you can use the legacy DOM or the W3C standard DOM method. This is a good thing.
In fact, the core of the above question is systematization and concreteness, which is something I think is very important in the learning process. This really solved a lot of doubts for me.
To get out of the beginner’s dilemma, we need systematic knowledge and concrete thoughts. Thank you for taking the time to read this article. I hope it will be helpful to you. If you want to discuss more issues, please add me on QQ: 303551651.

Python is more suitable for beginners, with a smooth learning curve and concise syntax; JavaScript is suitable for front-end development, with a steep learning curve and flexible syntax. 1. Python syntax is intuitive and suitable for data science and back-end development. 2. JavaScript is flexible and widely used in front-end and server-side programming.

Python and JavaScript have their own advantages and disadvantages in terms of community, libraries and resources. 1) The Python community is friendly and suitable for beginners, but the front-end development resources are not as rich as JavaScript. 2) Python is powerful in data science and machine learning libraries, while JavaScript is better in front-end development libraries and frameworks. 3) Both have rich learning resources, but Python is suitable for starting with official documents, while JavaScript is better with MDNWebDocs. The choice should be based on project needs and personal interests.

The shift from C/C to JavaScript requires adapting to dynamic typing, garbage collection and asynchronous programming. 1) C/C is a statically typed language that requires manual memory management, while JavaScript is dynamically typed and garbage collection is automatically processed. 2) C/C needs to be compiled into machine code, while JavaScript is an interpreted language. 3) JavaScript introduces concepts such as closures, prototype chains and Promise, which enhances flexibility and asynchronous programming capabilities.

Different JavaScript engines have different effects when parsing and executing JavaScript code, because the implementation principles and optimization strategies of each engine differ. 1. Lexical analysis: convert source code into lexical unit. 2. Grammar analysis: Generate an abstract syntax tree. 3. Optimization and compilation: Generate machine code through the JIT compiler. 4. Execute: Run the machine code. V8 engine optimizes through instant compilation and hidden class, SpiderMonkey uses a type inference system, resulting in different performance performance on the same code.

JavaScript's applications in the real world include server-side programming, mobile application development and Internet of Things control: 1. Server-side programming is realized through Node.js, suitable for high concurrent request processing. 2. Mobile application development is carried out through ReactNative and supports cross-platform deployment. 3. Used for IoT device control through Johnny-Five library, suitable for hardware interaction.

I built a functional multi-tenant SaaS application (an EdTech app) with your everyday tech tool and you can do the same. First, what’s a multi-tenant SaaS application? Multi-tenant SaaS applications let you serve multiple customers from a sing

This article demonstrates frontend integration with a backend secured by Permit, building a functional EdTech SaaS application using Next.js. The frontend fetches user permissions to control UI visibility and ensures API requests adhere to role-base

JavaScript is the core language of modern web development and is widely used for its diversity and flexibility. 1) Front-end development: build dynamic web pages and single-page applications through DOM operations and modern frameworks (such as React, Vue.js, Angular). 2) Server-side development: Node.js uses a non-blocking I/O model to handle high concurrency and real-time applications. 3) Mobile and desktop application development: cross-platform development is realized through ReactNative and Electron to improve development efficiency.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Zend Studio 13.0.1
Powerful PHP integrated development environment

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Atom editor mac version download
The most popular open source editor