最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Example of a JavaScript binding that is part of the language standard - Stack Overflow

programmeradmin0浏览0评论

The online book Eloquent JavaScript has the following phrase in Chapter 2 while talking about the environment:

When a program starts up, this environment is not empty. It always contains bindings that are part of the language standard, and most of the time, it also has bindings that provide ways to interact with the surrounding system.

I'm don't understand what it means by "bindings that are part of the language standard." I've been looking for examples on the Internet, but I can't find any, even though I've seen similar statements to what Eloquent JavaScript says.

Can anybody name some specific examples of these language standard bindings?

The online book Eloquent JavaScript has the following phrase in Chapter 2 while talking about the environment:

When a program starts up, this environment is not empty. It always contains bindings that are part of the language standard, and most of the time, it also has bindings that provide ways to interact with the surrounding system.

I'm don't understand what it means by "bindings that are part of the language standard." I've been looking for examples on the Internet, but I can't find any, even though I've seen similar statements to what Eloquent JavaScript says.

Can anybody name some specific examples of these language standard bindings?

Share Improve this question edited Feb 1 at 20:21 InSync 10.9k4 gold badges17 silver badges55 bronze badges asked Feb 1 at 20:09 apex2022apex2022 8552 gold badges12 silver badges34 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 4

In the book Eloquent JavaScript, the term binding is synonymous with variable, as stated in chapter 2:

To catch and hold values, JavaScript provides a thing called a binding, or variable.

let caught = 5 * 5;

That gives us a second kind of statement. The special word (keyword) let indicates that this sentence is going to define a binding. It is followed by the name of the binding and, if we want to immediately give it a value, by an = operator and an expression.

The example creates a binding called caught and uses it to grab hold of the number that is produced by multiplying 5 by 5.

When it speaks of standard bindings, the global names are intended that are already defined before anything in your script has executed, and which belong to the core language (as found in the ECMAScript specification).

Well-known examples are undefined, parseInt, Array, Math, Date, RegExp, Promise, JSON, ...

You can find a more comprehensive list in the article Standard built-in objects written by Mozilla Contributors.

In JavaScript, a binding refers to the association between an identifier (such as a variable or function name) and a value, object or function. I don't find the term in this context particularity providing much clarity.

Examples of binding which are used to interact with the surrounding system are:

  • window – Represents the browser window and provides global access to various browser features.
  • fetch() - Used to make HTTP(S) requests.
  • getTime() - Gets the system time
  • console - Object which gives access to console functions

So fetch is the identifier, the name, bound to function performing the actual fetch. That together is the binding.

An example of a predefined binding which does not interact with the surrounding system is: undefined.

发布评论

评论列表(0)

  1. 暂无评论