This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var a = 'hi'; | |
function myFunction(){ | |
var a; // the a in the local scope is hoisted here and a is 'undefined | |
console.log(a); // outputs 'undefined | |
a = 'hello'; | |
console.log(a); // outputs 'hello' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function myFunction(){ | |
a; | |
console.log(a); | |
let a = 'hello'; | |
} | |
myFunction(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function myFunction(){ | |
let a; // a's declaration is hoisted here, but remains uninitialized | |
a // Will get a ReferenceError: Cannot access 'a' before initialization | |
console.log(a); | |
} | |
myFunction(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function myFunction(){ | |
let a; // a's declaration is hoisted here, but remains uninitialized | |
a; // Will get a ReferenceError: Cannot access 'a' before initialization | |
console.log(a); | |
a = 'hello'; // everything above this line of code is referenced as temporal dead zone | |
} | |
myFunction(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
class Parent extends React.Component{ | |
constructor(props){ | |
super(props); | |
this.state = { | |
data: 'Data from parent' | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
function Parent(){ | |
const data = 'Data from parent'; | |
return( | |
<div> | |
<Child dataParentToChild = {data}/> | |
</div> | |
) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
class Parent extends React.Component{ | |
constructor(props){ | |
super(props); | |
this.state = { | |
data: null | |
} | |
} |
OlderNewer