Javascript 在《茉莉花》中,beforeAll()和let之间有什么区别吗?

Javascript 在《茉莉花》中,beforeAll()和let之间有什么区别吗?,javascript,jasmine,ecmascript-6,Javascript,Jasmine,Ecmascript 6,我试着想清楚这一点,读了这么多问题,我做了一个小测试: describe("let", () => { let x = 1; it("",function() { console.log(x + "<< it"); console.log(y + "<< it"); }); }); describe("beforeAll()", () => { let x; let y = 2; beforeAll(() =>

我试着想清楚这一点,读了这么多问题,我做了一个小测试:

describe("let", () => {
  let x = 1;
  it("",function() {
    console.log(x + "<< it");
    console.log(y + "<< it");
  });
});

describe("beforeAll()", () => {
  let x;
  let y = 2;
  beforeAll(() => {
    x = 1;
  });
  it("",function() {
    console.log(x + "<< it");
    console.log(y + "<< it");
  });
});
description(“let”,()=>{
设x=1;
它(“,函数(){

console.log(x+“
之前
回调可以访问spec
,并且可以是异步的

如果规范中未使用
上下文,我建议对常量使用
let
/
const
,对设置操作使用
before
(之后可以选择与
配对)

LOG: '1<< it'
LOG: 'undefined<< it'
LOG: '1<< it'
LOG: '2<< it'