pub enum DeclarationList {
Const(Box<[Declaration]>),
Let(Box<[Declaration]>),
Var(Box<[Declaration]>),
}Variants§
Const(Box<[Declaration]>)
The const statements are block-scoped, much like variables defined using the let
keyword.
This declaration creates a constant whose scope can be either global or local to the block in which it is declared. Global constants do not become properties of the window object, unlike var variables.
An initializer for a constant is required. You must specify its value in the same statement in which it’s declared. (This makes sense, given that it can’t be changed later.)
More information:
Let(Box<[Declaration]>)
The let statement declares a block scope local variable, optionally initializing it to a
value.
let allows you to declare variables that are limited to a scope of a block statement, or
expression on which it is used, unlike the var keyword, which defines a variable
globally, or locally to an entire function regardless of block scope.
Just like const the let does not create properties of the window object when declared
globally (in the top-most scope).
More information:
Var(Box<[Declaration]>)
The var statement declares a variable, optionally initializing it to a value.
var declarations, wherever they occur, are processed before any code is executed. This is called hoisting, and is discussed further below.
The scope of a variable declared with var is its current execution context, which is either the enclosing function or, for variables declared outside any function, global. If you re-declare a JavaScript variable, it will not lose its value.
Assigning a value to an undeclared variable implicitly creates it as a global variable (it becomes a property of the global object) when the assignment is executed.
More information:
Trait Implementations§
Source§impl AsRef<[Declaration]> for DeclarationList
impl AsRef<[Declaration]> for DeclarationList
Source§fn as_ref(&self) -> &[Declaration]
fn as_ref(&self) -> &[Declaration]
Source§impl Clone for DeclarationList
impl Clone for DeclarationList
Source§fn clone(&self) -> DeclarationList
fn clone(&self) -> DeclarationList
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more