Block Binding in ES6

What is Binding?

VAR Binding: Confusion

function getValue(condition) {

if (condition) {
var value = "blue";

// other code

return value;
} else {

// value exists here with a value of undefined

return null;
}

// value exists here with a value of undefined
}

Loops and block-level declarations

for (var i = 0; i < 10; i++)
{
// code goes here
}
console.log(i); // still works!
for (let i = 0; i < 10; i++)
{
}console.log(i); // error!

Loops and ‘const’ declarations

for (const i = 0; i < 5; i++)
{
// will only run one time before error
}
var car = {
make: 'Honda',
model: 'Fit'
};
for (const key in car){
console.log(key); // totally fine
}

Summary

2. AsyncFunction

async function f() {
return 1;
}
async function f() {
return 1;
}

f().then(alert); // 1
async function f() {
return Promise.resolve(1);
}

f().then(alert); // 1

3. awaitFunction

// works only inside async functions
let value = await promise;
async function f() {

let promise = new Promise((resolve, reject) => {
setTimeout(() => resolve("done!"), 1000)
});

let result = await promise; // wait until the promise resolves (*)

alert(result); // "done!"
}

f();

4.typeof()

for Example :

5.Equality (==)

for Example :

console.log(1 == 1);
// expected output: true
console.log('hello' == 'hello');
// expected output: true
console.log('1' == 1);
// expected output: true
console.log(0 == false);
// expected output: true

6.Spread Operator

for Example :

const inputValue = [...value];

7. Arrow functions

for Example :

const multify = (x) => {return (x*x);};
console.log(multify(9));
------------------------
const nums = [
'100',
'2003',
'30004',
'4005'
];
console.log(nums.map(num => num.length));
//expected output:Array [3, 4, 5, 4]

8. Anonymous Functions

let show = ()=> {     
console.log('Anonymous function');
};
show();

Summary

9.JavaScript prototype

console.log(Object);
console.log(Object.prototype);

10. What is https

HyperText Transfer Protocol Secure

--

--

--

javaScript developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How to Integrate Google Sign-in Authentication into a Crowdbotics Mobile App

heroku server, client setting

Beginner Coders, Here’s 5 Reasons Why You Should Stop Using IDEs

Why we’re migrating unit tests to Jest (and why you should too)

React Native: Is It Worth It? (Part I)

Javascript — Writing Map as a Recursive Function

Solution To Traffic Fine Related Problem…

MATLAB Code for Study of Discrete Fourier Transform (DFT) and its linearity and convolution…

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Mozumder Neaz

Mozumder Neaz

javaScript developer

More from Medium

Push and Pulley, Flatiron Phase 1 Project.

cs371p Spring 2022 Week 14: Badr Belhiti

Mozilla contribute playbook

CS3240 Design Exercise