Skip to content

Commit 04e0b53

Browse files
committed
added
1 parent 4a43594 commit 04e0b53

14 files changed

Lines changed: 248 additions & 1 deletion

File tree

docs/.nojekyll

Whitespace-only changes.

docs/index.html

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>10secondsofcode - The team behind 10-seconds-of-code and official 10-seconds projects.</title>
6+
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
7+
<meta name="description" content="The team behind 10-seconds-of-code and official 10-seconds projects.">
8+
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
9+
<link rel="stylesheet" href="//unpkg.com/docsify/lib/themes/vue.css">
10+
</head>
11+
<body>
12+
<div id="app"></div>
13+
<script>
14+
window.$docsify = {
15+
name: '10secondsofcode',
16+
basePath: '/docs/',
17+
loadNavbar: true,
18+
repo: 'https://github.com/10secondsofcode/10secondsofcode'
19+
}
20+
</script>
21+
<script src="//unpkg.com/docsify/lib/docsify.min.js"></script>
22+
</body>
23+
</html>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"start": "webpack-dev-server --mode development ",
99
"dev": "webpack --mode development --output ./dist/leaf.js",
1010
"build": "webpack --mode production --output ./dist/leaf.js",
11-
"docs-build":"gitbook build docs/ dist/docs",
11+
"docs-build": "cp -r docs/. public",
1212
"predeploy": "npm run build",
1313
"deploy": "gh-pages -d dist"
1414
},

public/.nojekyll

Whitespace-only changes.

public/Notes.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# RefLink
2+
3+
1. https://ponyfoo.com/articles/es6
4+
2. https://github.com/sudheerj/reactjs-interview-questions

public/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
# 10secondsofcode
3+
10secondsofcode is a easy way to understand the reactjs snippets in 10 seconds. [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2F10secondsofcode%2F10secondsofcode.svg?type=small)](https://app.fossa.io/projects/git%2Bgithub.com%2F10secondsofcode%2F10secondsofcode?ref=badge_small)
4+
5+
*Website :* [https://10secondsofcode.github.io/10secondsofcode/](https://10secondsofcode.github.io/10secondsofcode/)
6+
7+
## Getting Started
8+
9+
```
10+
git clone https://github.com/10secondsofcode/10secondsofcode.git
11+
npm install
12+
npm start
13+
```
14+
15+
## Built With
16+
17+
* [ReactJs](https://github.com/reactjs)
18+
* [BootStrap4](https://getbootstrap.com/docs/4.1/getting-started/introduction/)
19+
20+
## Contributing
21+
22+
If you have any idea for an improvement or found a bug, do not hesitate to open an issue. And if you have time clone this repo and submit a pull request and help me make *10secondsofcode*, we all dream about! Please read [CONTRIBUTING.md](https://github.com/10secondsofcode/10secondsofcode/blob/master/CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.
23+
24+
## Authors
25+
26+
See also the list of [contributors](https://github.com/your/project/contributors) who participated in this project.
27+
28+
## License
29+
30+
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details
31+
32+
## Acknowledgments
33+
34+
* Hat tip to anyone whose code was used
35+
* Inspiration
36+
* etc
37+

public/SUMMARY.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Summary
2+
3+
### Part I
4+
5+
* [Writing is nice](chapter1/README.md)
6+
* [GitBook is nice](chapter1/something.md)
7+
8+
### Part II
9+
10+
* [Writing is nice](chapter2/README.md#writing)
11+
* [GitBook is nice](chapter2/something.md#gitbook)

public/chapter-1/README.md

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# Chapter 1
2+
3+
#Javascripts:
4+
5+
var - The scope of a variable declared with the keyword var is its current execution context.
6+
Let - let are block scoped and not function scoped.
7+
8+
#Hoisting functions
9+
10+
Function declarations
11+
12+
hoisted(); // Output: "This function has been hoisted."
13+
14+
function hoisted() {
15+
console.log('This function has been hoisted.');
16+
};
17+
18+
Function expressions
19+
20+
Function expressions, however are not hoisted.
21+
22+
expression(); // Ouput: TypeError: expression is not a function
23+
24+
var expression = function hoisting() {
25+
console.log('Will this work?');
26+
};
27+
28+
29+
https://scotch.io/tutorials/understanding-hoisting-in-javascript
30+
31+
async / await
32+
promises
33+
callbacks
34+
35+
#Async/await
36+
37+
Async/await is a new way to write asynchronous code. Previous options for asynchronous code are callbacks and promises.
38+
Async/await is actually built on top of promises. It cannot be used with plain callbacks or node callbacks.
39+
Async/await is, like promises, non blocking.
40+
Async/await makes asynchronous code look and behave a little more like synchronous code. This is where all its power lies.
41+
42+
const makeRequest = () =>
43+
getJSON()
44+
.then(data => {
45+
console.log(data)
46+
return "done"
47+
})
48+
49+
makeRequest()
50+
51+
const makeRequest = async () => {
52+
console.log(await getJSON())
53+
return "done"
54+
}
55+
56+
makeRequest()
57+
58+
#closures
59+
60+
A closure is an inner function that has access to the outer (enclosing) function’s variables—scope chain. The closure has three scope chains:
61+
- it has access to its own scope (variables defined between its curly brackets).
62+
- it has access to the outer function’s variables.
63+
- it has access to the global variables.
64+
65+
Closure means that an inner function always has access to the vars and parameters of its outer function, even after the outer function has returned.
66+
67+
Inner function can access variables and parameters of an outer function.
68+
It is useful in hiding implementation detail in JavaScript.
69+
70+
function showName (firstName, lastName) {
71+
var nameIntro = "Your name is ";
72+
// this inner function has access to the outer function's variables, including the parameter
73+
function makeFullName () {
74+
return nameIntro + firstName + " " + lastName;
75+
}
76+
77+
return makeFullName ();
78+
}
79+
80+
showName ("Michael", "Jackson"); // Your name is Michael Jackson
81+
82+
function OuterFunction() {
83+
84+
var outerVariable = 100;
85+
86+
function InnerFunction() {
87+
alert(outerVariable);
88+
}
89+
90+
return InnerFunction;
91+
}
92+
var innerFunc = OuterFunction();
93+
94+
innerFunc(); // 100
95+
96+
97+
function Counter() {
98+
var counter = 0;
99+
100+
function IncreaseCounter() {
101+
return counter += 1;
102+
};
103+
104+
return IncreaseCounter;
105+
}
106+
107+
var counter = Counter();
108+
alert(counter()); // 1
109+
alert(counter()); // 2
110+
alert(counter()); // 3
111+
alert(counter()); // 4
112+
113+
In the above example, return InnerFunction; returns InnerFunction from OuterFunction when you call OuterFunction(). A variable innerFunc reference the InnerFunction() only, not the OuterFunction(). So now, when you call innerFunc(), it can still access outerVariable which is declared in OuterFunction(). This is called Closure.
114+
115+
#IIFE
116+
117+
IIFE is a function expression that automatically invokes after completion of the definition.
118+
The parenthesis () plays important role in IIFE pattern.
119+
use () operator to call this anonymous function immediately after completion of its definition.
120+
(function () {
121+
//write your js code here
122+
})();
123+
124+
Adcvantages:
125+
126+
Do not create unnecessary global variables and functions
127+
Functions and variables defined in IIFE do not conflict with other functions & variables even if they have same name.
128+
Organize JavaScript code.
129+
Make JavaScript code maintainable.
130+
131+
#this():
132+
133+
The following four rules applies to this in order to know which object is referred by this keyword.
134+
135+
Global Scope
136+
Object's Method
137+
call() or apply() method
138+
bind() method

public/chapter-1/something.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Chapter 1
2+
3+
## Something

public/chapter-2/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Chapter 2

0 commit comments

Comments
 (0)