Javascript.info Ebook Part 1 The JavaScript language (2019).pdf

所需积分/C币:50 2019-10-10 13:18:32 7.33MB PDF
收藏 收藏
举报

当代javascript教程,涵盖dom和相关语言基础。非常推荐,内容面向现代javascript语法
Methods of primitives Numbers Strings Arrays Array methods Iterables Map, Set, Weak Map and Weakset Object keys, values, entries Destructuring assignment Date and time JSoN methods. toJSON Advanced working with functions Recursion and stack Rest parameters and spread operator Closure The old var Global object Function object, NFE The"new Function" syntax Scheduling: setTimeout and setInterval Decorators and forwarding, call/apply Function binding Currying and partials Arrow functions revisited Object properties confiquration Property flags and descriptors Property getters and setters Prototypes, inheritance Prototypal inheritance F prototype Native prototypes Prototype methods, objects without -proto Classes Class basic syntax Class inheritance Static properties and methods Private and protected properties and methods Extending built-in classes Class checking: instanceof Mixins Error handling Error handling, "try. catch Custom errors, extending error Promises, async/await Introduction: callbacks Promise Promises chaining Error handling with promises Promise apl Promisification Microtasks Async/await Generators. advanced iteration Generators Async iterators and generators Modules Modules. introduction Export and Import Dynamic imports Miscellaneous Proxy and reflect Eval: run a code string Here we learn JavaScript, starting from scratch and go on to advanced concepts like OOP We concentrate on the language itself here, with the minimum of environment-specific notes An introduction about the javascript language and the environment to develop with it An Introduction to JavaScript Let's see what's so special about JavaScript, what we can achieve with it, and which other technologies play well with it What is JavaScript? Java script was initially created to "make web pages alive The programs in this language are called scripts. They can be written right in a web page's HTML and run automatically as the page loads Scripts are provided and executed as plain text. They don't need special preparation or compilation to run In this aspect, Javascript is very different from another language called Java G Why JavaScript? When JavaScript was created, it initially had another name: "Live Script". But Java was very popular at that time, so it was decided that positioning a new language as a"younger brother"of Java would help But as it evolved, JavaScript became a fully independent language with its own specification called ECMAScript c, and now it has no relation to Java at all Today, JavaScript can execute not only in the browser, but also on the server, or actually on any device that has a special program called the JavaScript engine L The browser has an embedded engine sometimes called a javascript virtual machine' Different engines have different "codenames". for example: V8 r-in Chrome and opera SpiderMonkey c -in Firefox There are other codenames like "Trident and "Chakra" for different versions of ie ChakraCore" for Microsoft Edge, Nitro"and "SquirrelFish for Safari, etc The terms above are good to remember because they are used in developer articles on the internet. We'll use them too. For instance, if"a feature X is supported by v8", then it probably works in Chrome and Opera How do engines work? Engines are complicated. But the basics are easy 1. the engine(embedded if it's a browser) reads(parses")the script 2. Then it converts("compiles)the script to the machine language 3. And then the machine code runs, pretty fast The engine applies optimizations at each step of the process. It even watches the compiled script as it runs, analyzes the data that flows through it, and applies optimizations to the machine code based on that knowledge When it's done scripts run quite fast What can in-browser Javascript do? Modern Java Script is a safe"programming language. It does not provide low-level access to memory or CPU, because it was initially created for browsers which do not require it Javascript 's capabilities greatly depend on the environment it's running in. For instance, Node js c supports functions that allow Java Script to read/write arbitrary files, perform network requests, etc In-browser Javascript can do everything related to webpage manipulation, interaction with the user and the webserver For instance, in-browser JavaScript is able to Add new HTML to the page, change the existing content, modify styles React to user actions, run on mouse clicks, pointer movements, key presses Send requests over the network to remote servers, download and upload files(so-called AJAX c and COMET L technologies) Get and set cookies, ask questions to the visitor, show messages Remember the data on the client-side(local storage") What CAN'T in-browser JavaScript do? Javascript's abilities in the browser are limited for the sake of the user' s safety the aim is to prevent an evil webpage from accessing private information or harming the user's data EXamples of such restrictions include Javascript on a webpage may not read/write arbitrary files on the hard disk, copy them or execute programs. It has no direct access to OS system functions Modern browsers allow it to work with files, but the access is limited and only provided if the user does certain actions, like"dropping a file into a browser window or selecting it via an <Input> tag There are ways to interact with camera/microphone and other devices, but they require a user's explicit permission. So a JavaScript-enabled page may not sneakily enable a web camera, observe the surroundings and send the information to the nsa tt Different tabs/windows generally do not know about each other. Sometimes they do, for example when one window uses JavaScript to open the other one. But even in this case, JavaScript from one page may not access the other if they come from different sites( from a different domain, protocol or port This is called the " Same Origin Policy". To work around that, both pages must agree for data exchange and contain a special Javascript code that handles it. We'll cover that in the tutorial ThislimitationisagainfortheuserssafetyApagefromhttp://anysite.comwhicha user has opened must not be able to access another browser tab with the URL http://gmail.comandstealinformationfromthere Javascript can easily communicate over the net to the server where the current page came from. But its ability to receive data from other sites/domains is crippled. Though possible, it requires explicit agreement(expressed in Http headers) from the remote side once again that's a safety limitation httpjavascriptInfo ooohttpj/javascript.info ooo htt w/gmall. com - rD </script≥ > Such limits do not exist if Java Script is used outside of the browser, for example on a server Modern browsers also allow plugin/extensions which may ask for extended permissions What makes JavaScript unique? There are at least three great things about JavaScript Full integration with HTML/CSS Simple things are done simply Support by all major browsers and enabled by default Javascript is the only browser technology that combines these three things That's what makes Java Script unique. That's why it 's the most widespread tool for creating browser interfaces While planning to learn a new technology, it's beneficial to check its perspectives. So let's move on to the modern trends affecting it, including new languages and browser abilities Languages“over” Javascript The syntax of Javascript does not suit everyone s needs. Different people want different features That's to be expected, because projects and requirements are ditterent for everyone So recently a plethora of new languages appeared, which are transpiled(converted ) to Javascript before they run in the browser Modern tools make the transplation very fast and transparent, actually allowing developers to code in another language and auto-converting it"under the hood Examples of such languages CoffeeScript c is a syntactic sugar"for JavaScript. It introduces shorter syntax, allowing us to write clearer and more precise code. Usually, Ruby devs like it Type Script c is concentrated on adding" strict data typing "to simplify the development and support of complex systems. It is developed by microsoft Flow c also adds data typing, but in a different way. Developed by Facebook Dart L is a standalone language that has its own engine that runs in non-browser environments(like mobile apps), but also can be transpiled to JavaScript. Developed by Google There are more. Of course, even if we use one of transpired languages, we should also know Javascript to really understand what were do Summa Javascript was initially created as a browser-only language, but is now used in many other environments as well Today, Javascript has a unique position as the most widely-adopted browser language with full integration with HTML/CSS There are many languages that get"transpiledto JavaScript and provide certain features. It is recommended to take a look at them, at least briefly, after mastering JavaScript Manuals and specifications This book is a tutorial. It aims to help you gradually learn the language. But once you're familiar with the basiCS, you'll need other sources Specification The ECMA-262 specification contains the most in-depth, detailed and formalized information about JavaScript. It defines the language But being that formalized, it,'s difficult to understand at first. So if you need the most trustworthy source of information about the language details, the specification is the right place. But it's not for everyday use Thelatestdraftisathttps://tc39.es/ecma262/ To read about new bleeding-edge features, that are"almost standard,, see proposals at https:/github.com/tc39/proposalsc Also, if you're in developing for the browser, then there are other specs covered in the second part of the tutorial Manuals MDN(Mozilla JavaScript Reference is a manual with examples and other information It's great to get in-depth information about individual language functions, methods etc Onecanfinditathttpsdevelopermozillaorglen-us/docs/web/javasCript/referencec Although, it's often best to use an internet search instead. Just use MdN [term] in the query, e.g.https:/google.com/search?q=mdn+parseintcttosearchforparseintfunction MSDN- Microsoft manual with a lot of information, including JavaScript (often referred to as JScript). If one needs something specific to Internet Explorer, better go there http://msdn.microsoftcom/ct Also, we can use an internet search with phrases such as" RegExp MsDN"or"RegEXp MSDN jscript Feature support Javascript is a developing language, new features get added regularly To see their support among browser-based and other engines, see http:/caniuse.comc-per-featuretablesofsupporte.g.toseewhichenginessupport moderncryptographyfunctionshttp://caniuse.com/#feat=cryptographyL https://kangax.github.io/compat-tablec-atablewithlanguagefeaturesandenginesthat support those or don't support All these resources are useful in real-life development, as they contain valuable information about language details, their support etc Please remember them (or this page) for the cases when you need in-depth information about a particular feature Code editors a code editor is the place where programmers spend most of their time There are two main types of code editors: IDEs and lightweight editors. Many people use one tool of each type IDE The term IDE c(Integrated Development Environment refers to a powerful editor with many features that usually operates on a whole project. "As the name suggests, it's not just an editor, but a full-scale“ development environment;” An iDE loads the project (which can be many files), allows navigation between files, provides autocompletion based on the whole project(not just the open file), and integrates with a version management system (like git c ) a testing environment, and other "project-level"stuff If you haven 't selected an ide yet, consider the following options: Visual Studio Code c(cross-platform, free) WebStorm c(cross-platform, paid) For Windows there's also visual studio not to be confused with visual studio code ,"Visual Studio"is a paid and mighty Windows-only editor, well-suited for the. NET platform. It 's also good at JavaScript. There's also a free version Visual Studio Community c Many IDEs are paid, but have a trial period. Their cost is usually negligible compared to a qualified developer's salary, so just choose the best one for you Lightweight editors Lightweight editors"are not as powerful as IDES, but they're fast, elegant and simple They are mainly used to open and edit a file instantly The main difference between a"lightweight editor"and an"IDE"is that an IDE works on a project-level, so it loads much more data on start, analyzes the project structure if needed and so on. a lightweight editor is much faster if we need only one file In practice, lightweight editors may have a lot of plugins including directory-level syntax analyzers and autocompleters, so there's no strict border between a lightweight editor and an IDE The following options deserve your attention Atom c(crOss-platform, free) Sublime Text c(cross-platform, shareware) Notepad++ t(Windows, free) Vim c and emacs c are also cool if you know how to use them Let's not argue The editors in the lists above are those that either I or my friends whom I consider good developers have been using for a long time and are happy with There are other great editors in our big world. Please choose the one you like the most

...展开详情
试读 127P Javascript.info Ebook Part 1 The JavaScript language (2019).pdf
立即下载 低至0.43元/次 身份认证VIP会员低至7折
    一个资源只可评论一次,评论内容不能少于5个字
    yj920 英文的。。。。
    2020-02-07
    回复
    关注 私信 TA的资源
    上传资源赚积分,得勋章
    最新推荐
    Javascript.info Ebook Part 1 The JavaScript language (2019).pdf 50积分/C币 立即下载
    1/127
    Javascript.info Ebook Part 1 The JavaScript language (2019).pdf第1页
    Javascript.info Ebook Part 1 The JavaScript language (2019).pdf第2页
    Javascript.info Ebook Part 1 The JavaScript language (2019).pdf第3页
    Javascript.info Ebook Part 1 The JavaScript language (2019).pdf第4页
    Javascript.info Ebook Part 1 The JavaScript language (2019).pdf第5页
    Javascript.info Ebook Part 1 The JavaScript language (2019).pdf第6页
    Javascript.info Ebook Part 1 The JavaScript language (2019).pdf第7页
    Javascript.info Ebook Part 1 The JavaScript language (2019).pdf第8页
    Javascript.info Ebook Part 1 The JavaScript language (2019).pdf第9页
    Javascript.info Ebook Part 1 The JavaScript language (2019).pdf第10页
    Javascript.info Ebook Part 1 The JavaScript language (2019).pdf第11页
    Javascript.info Ebook Part 1 The JavaScript language (2019).pdf第12页
    Javascript.info Ebook Part 1 The JavaScript language (2019).pdf第13页
    Javascript.info Ebook Part 1 The JavaScript language (2019).pdf第14页
    Javascript.info Ebook Part 1 The JavaScript language (2019).pdf第15页
    Javascript.info Ebook Part 1 The JavaScript language (2019).pdf第16页
    Javascript.info Ebook Part 1 The JavaScript language (2019).pdf第17页
    Javascript.info Ebook Part 1 The JavaScript language (2019).pdf第18页
    Javascript.info Ebook Part 1 The JavaScript language (2019).pdf第19页
    Javascript.info Ebook Part 1 The JavaScript language (2019).pdf第20页

    试读已结束,剩余107页未读...

    50积分/C币 立即下载 >