JS

JSON.stringfy

无法解析 JSX,原因是 JSX 对象中存在循环引用
https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify
大概是 JSX 对象中引用的 context 对象,context 中肯定又有当前使用的 JSX

HTTP

“CAUTION: provisional headers are shown” in Chrome debugger

provisional headers are shown出现的情况有这么几种:

  1. 跨域,请求被浏览器拦截(此时请求状态肯定是 CORS)
  2. 请求被浏览器插件拦截
  3. 服务器出错或者超时,没有真正的返回
  4. 强缓存from disk cache或者from memory cache,此时也不会显示 (此时请求状态肯定是 200 cache)

原因 sentry 添加了额外的 request header,导致 CROS 中对不上,服务器不响应。
https://enable-cors.org/server.html
解决方式:

  1. 请求中去除该请求头
  2. 后端支持这个额外的请求头

https://docs.sentry.io/platforms/javascript/performance/instrumentation/automatic-instrumentation/#tracingorigins
You will need to configure your web server CORS to allow the sentry-trace header. The configuration might look like "Access-Control-Allow-Headers: sentry-trace", but the configuration depends on your set up. If you do not allow the sentry-trace header, the request might be blocked.
一般是在 nginx 中进行配置 Access-Control-Allow-Headers
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers

Node

JavaScript Heap Out Of Memory Error

该错误经常出现在 node 版本太低的环境中

  1. // 简单配置
  2. node --max-old-space-size=4096 index.js

https://blog.asayer.io/javascript-heap-out-of-memory-error
image.png

SICP

it is crucial that each function accomplishes an identifiable task that can be used as a module in defining other functions
每个函数都要完成一个可识别的任务,该任务可以用作定义其他函数的模块

when we define theisgood_enoughfunction in terms ofsquare, we are able to regard thesquarefunction as a black box.
We are not at that moment concerned with
how the function computes its result, only with the fact that it computes the square.
将函数视为黑盒,不关注如何计算,只关注函数做了什么。
相比函数内部的实际计算组成,组合后的函数更像一个抽象的函数。
这样的函数生成方式是 **_f__unctional abstraction
**
a function should be able to suppress detail.
函数应该能抑制细节

A parameter of a function has a very special role in the function declaration, in that it doesn’t matter what name the parameter has. Such a name is called bound, and we say that the function declaration binds its parameters. If a name is not bound, we say that it is free.
函数与它的参数绑定

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name#bound_function_names 这里记录一下 MDN 中函数 bound 的一些内容,与这里的内容类似,但完全不想干 image.png

The set of expressions for which a binding declares a name is called the scope _of that name.
Any matching pair of braces designates a
block_, and declarations inside the block are local to the block.
大括号代表块,块内声明只在块内生效
Since x is bound in the declaration of sqrt, the functions is_good_enough, improve, and sqrt_iter, which are declared internally to sqrt, are in the scope of x. Thus, it is not necessary to pass x explicitly to each of these functions. Instead, we allow x to be a free name in the internal declarations,Then x gets its value from the argument with which the enclosing function sqrt is called. This discipline is called lexical scoping
词法作用域相当于一种准则或纪律,也就是某个变量声明在它当前的作用域中都是有效的,即使作用域中还有作用域,无需传递,已可取值。

We will use block structure extensively to help us break up large programs into tractable pieces.
广泛使用块结构帮助我们将大型程序分解成易于处理的部分