当前位置:   article > 正文

JavaScript词汇表

javascript单词大全

异步 (Asynchronous)

Code is asynchronous when you initiate something, forget about it, and when the result is ready you get it back without having to wait for it. The typical example is an AJAX call, which might take even seconds and in the meantime you complete other stuff, and when the response is ready, the callback function gets called. Promises and async/await are the modern way to handle async.

当您启动某件事,忘记它时,代码是异步的,当结果准备好时,您无需等待就可以将其取回。 典型的示例是AJAX调用,它可能需要花费甚至几秒钟的时间,同时您还要完成其他工作,并且当响应准备就绪时,就会调用回调函数。 承诺和异步/等待是处理异步的现代方法。

(Block)

In JavaScript a block is delimited curly braces ({}). An if statement contains a block, a for loop contains a block.

在JavaScript中,一个块用花括号( {} )分隔。 if语句包含一个块, for循环包含一个块。

块作用域 (Block Scoping)

With Function Scoping, any variable defined in a block is visible and accessible from inside the whole block, but not outside of it.

使用Function Scoping ,可以在整个内部(而不是在外部)看到和访问块中定义的任何变量。

打回来 (Callback)

A callback is a function that’s invoked when something happens. A click event associated to an element has a callback function that’s invoked when the user clicks the element. A fetch request has a callback that’s called when the resource is downloaded.

回调是在发生某些情况时调用的函数。 与元素关联的click事件具有一个回调函数,当用户单击该元素时会调用该回调函数。 提取请求具有下载资源时调用的回调。

陈述式 (Declarative)

A declarative approach is when you tell the machine what you need to do, and you let it figure out the details. React is considered declarative, as you reason about abstractions rather than editing the DOM directly. Every high level programming language is more declarative than a low level programming language like Assembler. JavaScript is more declarative than C. HTML is declarative.

声明性方法是当您告诉机器您需要做什么时,让它弄清楚细节。 React是声明性的,因为您推理抽象而不是直接编辑DOM。 每种高级编程语言都比像Assembler这样的低级编程语言更具声明性。 JavaScript比C具有更多声明性。HTML具有声明性。

倒退 (Fallback)

A fallback is used to provide a good experience when a user hasn’t access to a particular functionality. For example a user that browses with JavaScript disabled should be able to have a fallback to a plain HTML version of the page. Or for a browser that has not implemented an API, you should have a fallback to avoid completely breaking the experience of the user.

当用户无法访问特定功能时,可使用后备功能提供良好的体验。 例如,在禁用JavaScript的情况下浏览的用户应该能够回退到该页面的纯HTML版本。 或对于尚未实现API的浏览器,您应该进行后备以避免完全破坏用户的体验。

功能范围 (Function Scoping)

With Function Scoping, any variable defined in a function is visible and accessible from inside the whole function.

使用Function Scoping ,可以在整个函数内部看到和访问函数中定义的任何变量。

不变性 (Immutability)

A variable is immutable when its value cannot change after it’s created. A mutable variable can be changed. The same applies to objects and arrays.

变量在创建后无法更改时是不可变的。 可变变量可以更改。 对象和数组也是如此。

词汇范围 (Lexical Scoping)

Lexical Scoping is a particular kind of scoping which means that the value of a variable is defined by its position when it’s written. Not when it’s called, which is something that happens with the alternative, dynamic scoping (used in some other programming languages).

词法作用域定义是一种特殊的作用域定义,这意味着变量的值由其写入时的位置来定义。 不是在调用它时发生的,而是在动态范围界定 (在某些其他编程语言中使用)中发生的。

Polyfill (Polyfill)

A polyfill is a way to provide new functionality available in modern JavaScript or a modern browser API to older browsers. A polyfill is a particular kind of shim.

polyfill是一种为较旧的浏览器提供现代JavaScript或现代浏览器API中可用的新功能的方法。 填充胶是一种特殊的垫片

纯功能 (Pure function)

A function that has no side effects (does not modify external resources), and its output is only determined by the arguments. You could call this function 1M times, and given the same set of arguments, the output will always be the same.

没有副作用(不修改外部资源)的函数,其输出仅由参数确定。 您可以将此函数调用1M次,并且给定相同的参数集,输出将始终相同。

重新分配 (Reassignment)

JavaScript with var and let declaration allows you to reassign a variable indefinitely. With const declarations you effectively declare an immutable value for strings, integers, booleans, and an object that cannot be reassigned (but you can still modify it through its methods).

带有varlet声明JavaScript允许您无限期地重新分配变量。 使用const声明,您可以有效地为字符串,整数,布尔值和无法重新分配的对象声明一个不可变的值(但是您仍然可以通过其方法对其进行修改)。

范围 (Scope)

Scope is, referred to a variable, in what portion of a program that variable is visible. let and const have block scoping, which determines a differnet scope from values defined using var, which have function scoping.

范围是指变量,在程序的哪个部分可见。 letconst具有块作用域,这确定了与使用var定义的值(具有函数作用域)不同的网络范围。

范围界定 (Scoping)

Scoping is how a programming language determines the scope of the variables and functions. We can for example have block scoping, function scoping, lexical scoping.

范围界定是一种编程语言如何确定变量和函数的范围。 例如,我们可以有块作用域,函数作用域,词法作用域。

垫片 (Shim)

A shim is a little wrapper around a functionality, or API. It’s generally used to abstract something, pre-fill parameters or add a polyfill for browsers that do not support some functionality. You can consider it like a compatibility layer.

填充程序是功能或API的小包装。 它通常用于抽象某些内容,预填充参数或为不支持某些功能的浏览器添加polyfill 。 您可以将其视为兼容层。

副作用 (Side effect)

A side effect is when a function interacts with some other function or object outside it. Interaction with the network or the file system, or with the UI, are all side effects.

副作用是函数与外部的其他函数或对象进行交互时。 与网络或文件系统或与UI的交互都是副作用。

(State)

State usually comes into play when talking about Components. A component can be stateful if it manages its own data, or stateless if it doesn’t.

在谈论组件时,状态通常会发挥作用。 如果组件管理自己的数据,则该组件可以是有状态的,否则,则可以是无状态的。

有状态的 (Stateful)

A stateful component, function or class manages its own state (data). It could store an array, a counter or anything else.

有状态的组件,函数或类管理自己的状态(数据)。 它可以存储一个数组,一个计数器或其他任何东西。

无状态 (Stateless)

A stateless component, function or class is also called dumb because it’s incapable of having its own data to make decisions, so its output or presentation is entirely based on its arguments. This implies that pure functions are stateless. Note: in React, what we once called stateless components are now called function components because hooks give them the ability to use state.

无状态的组件,函数或类也被称为哑巴,因为它无法拥有自己的数据来进行决策,因此其输出或表示完全基于其参数。 这意味着纯函数是无状态的。 注意:在React中,我们曾经称为无状态组件的现在称为功能组件,因为钩子使它们能够使用状态。

严格模式 (Strict mode)

Strict mode is an ECMAScript 5.1 new feature, which causes the JavaScript runtime to catch more errors, but it helps you improve the JavaScript code by denying undeclared variables and other things that might cause overlooked issues like duplicated object properties and other subtle things. Hint: use it. The alternative is “sloppy mode” which is not a good thing even looking at the name we gave it.

严格模式是ECMAScript 5.1的一项新功能,它使JavaScript运行时捕获更多错误,但它可以通过拒绝未声明的变量和其他可能导致被忽略的问题(例如重复的对象属性和其他细微的事情)的方法来改善JavaScript代码。 提示:使用它。 另一种选择是“草率模式”,即使看我们给它起的名字也不是一件好事。

摇树 (Tree Shaking)

Tree shaking means removing “dead code” from the bundle you ship to your users. If you add some code that you never use in your import statements, that’s not going to be sent to the users of your app, to reduce file size and loading time.

摇树意味着从您交付给用户的捆绑软件中删除“死代码”。 如果添加一些从未在导入语句中使用的代码,则不会将其发送给应用程序的用户,以减少文件大小和加载时间。

翻译自: https://flaviocopes.com/javascript-glossary/

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/956204
推荐阅读
相关标签
  

闽ICP备14008679号