string concatenation
firstname + ''+lastname;
`${firstname} ${lastname}';
function declarations
ES5
FUNCTION sayhello(){
console.log();
};
const sayHello =() => {console.log();}
var message = 'Hello,'+name+'!';
es6:
const message = `hELLO, ${NAME}!`;
COMBINE ARRAYS , SPREAD OPERATOR
OBJECT DESTRUCTURING
DEFAULT PARAMETER VALUES
scopes
Scope in JavaScript
Understanding scope in JavaScript is crucial for mastering the language. Scope determines the accessibility of variables and functions within your code.
Let's dive into the basics:
Global Scope:
Variables declared outside of any function have global scope and can be accessed from anywhere in your code.
Local Scope:
Variables declared inside a function have local scope and can only be accessed within that function.
Block Scope:
Block scope was introduced in ES6.
Variables declared with let and const have block scope, meaning they are only accessible within the block where they are defined (e.g., inside loops or conditional statements).
No comments:
Post a Comment