我试图为扩展运算符创建一个 polyfill。我的目标是创建类似于扩展运算符的东西,我可以使用三个@@@ 符号代替三个点。
例如,在 ES6 中
function sum(x, y, z) {
return x + y + z;
}
const numbers = [1, 2, 3];
console.log(sum(...numbers));
// expected output: 6
Run Code Online (Sandbox Code Playgroud)
我试图实现类似的功能
// Instead of triple dots, it should be triple @
console.log(sum(@@@numbers));
// expected output should be 6
Run Code Online (Sandbox Code Playgroud)
我希望的输出console.log(sum(@@@numbers));是6.
Recently I have come across about globalThis in Javascript. I am not sure how it is going to behave if it is called from a function. Every time it is returning the window object. if that is the case, then why don't we directly use the window object. What is necessary of using globalThis?
If I call the from a function, then it is returning window object Example:
(function test(){
console.log(globalThis); // returns window
})();
var obj = { …Run Code Online (Sandbox Code Playgroud) 根据 single-spa 官方文档,我们可以使用 RxJs 共享应用程序的 UI 状态。
Observables / Subjects (RxJs) - 一个微前端向一个流发出新值,该流可以被任何其他微前端使用。它从其浏览器模块中将 observable 导出到所有微前端,以便其他人可以导入它。
链接:https : //single-spa.js.org/docs/recommended-setup/#ui-state
链接:https : //single-spa.js.org/docs/faq/#how-can-i-share-application-state-between-applications
我试图在 React 中创建一个示例,其中我使用 single-spa 包裹将我的微应用程序包含在根应用程序中。我试图使用 RxJs 共享 UI 状态。当我在 google 上搜索 single-spa RxJs 时,我什么也没找到。谁能为我提供一个基本示例,我将能够为以下用例共享 UI 状态:
以下代码在 ES5 编译器中的输出是什么?它会抛出任何错误还是会正常工作?
let foo = 123;
let {x,y} = getValues();
Run Code Online (Sandbox Code Playgroud)