Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
151 commits
Select commit Hold shift + click to select a range
bc018ef
No need to install docsify-cli globally
niyonx Oct 25, 2019
bc3f956
High Order Functions tutorial
myk0la-b Oct 25, 2019
7572f24
replace variable declarations with var to modern let and const
ydegtyar Oct 25, 2019
5856926
Minor changes
Swap76 Oct 25, 2019
480cbcc
Update map_object.js
Swap76 Oct 25, 2019
d15a637
Update set_object.js
Swap76 Oct 25, 2019
46fe645
Update continue_break.js
Swap76 Oct 25, 2019
7c9fab3
Update switch_case.js
Swap76 Oct 25, 2019
d6e2d2a
Update variables.js
Swap76 Oct 25, 2019
1287bfd
Update arrow_function.md
ofarukcaki Oct 25, 2019
90937a3
Add documentation for Array.prototype.some()
Oct 25, 2019
9001c59
Updated Step 1
niyonx Oct 25, 2019
b0b0d85
new code added
Oct 25, 2019
3865eba
adding basic javascript exercise
Oct 26, 2019
8a14e39
Added content to prototype advanced content
dnafication Oct 26, 2019
7fdc601
Added JavaScript_Advance lesson on recursion
Oct 26, 2019
d7880a8
Update spread_&_rest.md
somecatdad Oct 26, 2019
014933f
added documentation on destructuring
Oct 26, 2019
ae873ba
Merge pull request #191 from ITGrusha/patch-1
Swap76 Oct 26, 2019
ef7c319
Merge pull request #202 from ydegtyar/master
Swap76 Oct 26, 2019
298255f
Merge pull request #212 from ofarukcaki/patch-1
Swap76 Oct 26, 2019
b267b9c
Merge pull request #213 from ondrej-merkun/ondrej-merkun/add-docs-for…
Swap76 Oct 26, 2019
8fcc51e
Merge pull request #185 from niyonx/patch-1
Swap76 Oct 26, 2019
bafff14
Merge pull request #214 from tomanistor/master
Swap76 Oct 26, 2019
728df22
Update arrow_function.js
Swap76 Oct 26, 2019
3495658
Merge pull request #215 from emo8355/newcode
Swap76 Oct 26, 2019
8364680
Merge pull request #216 from arthursvpb/arthur-branch
Swap76 Oct 26, 2019
2559244
Update prototype.md
Swap76 Oct 26, 2019
6f53761
Merge pull request #217 from dnafication/patch-1
Swap76 Oct 26, 2019
72f9915
Merge pull request #218 from travisallen6/recursion
Swap76 Oct 26, 2019
46b0ac2
Merge pull request #219 from sealedHuman/master
Swap76 Oct 26, 2019
7fd8927
Merge pull request #220 from travisallen6/destructuring-docs
Swap76 Oct 26, 2019
c90f606
New Commit
Oct 26, 2019
3f74c34
New Commit
Oct 26, 2019
de5f420
Changed names of exercise files
Swap76 Oct 26, 2019
a1f3214
Files moved to appropriate locations
Swap76 Oct 26, 2019
77d8e02
Added rule of no-var in eslint
Swap76 Oct 26, 2019
4f80f43
Add info on FS Module - Issue #206
frahmadani Oct 26, 2019
7716150
Closes #194;
vlastikwalker Oct 26, 2019
9d39b60
Added info about Timer Functions in JavaScript and corrected one spel…
shahpranaf Oct 26, 2019
0864864
Merge branch 'master' of https://github.com/shahpranaf/Learn-JavaScript
shahpranaf Oct 26, 2019
9a8c3a4
Add datatypes doc
Aman22sharma Oct 26, 2019
328427d
Add js hoisting
Aman22sharma Oct 26, 2019
24f2604
Update string_operation.md
ofarukcaki Oct 26, 2019
d0b9d8d
Add files via upload
WojciechPreficz Oct 26, 2019
484df44
Update variables.md
gumpdev Oct 26, 2019
0231156
ft(readme): add a readme about destructuring in js
NiyoEric Oct 26, 2019
3be4c7b
ft(readme): add a readme about nodejs express
NiyoEric Oct 26, 2019
e48966e
Revert "ft(mistake): push on wrong PR"
NiyoEric Oct 26, 2019
24139c3
ft(express): how to use express.js
NiyoEric Oct 26, 2019
41ec30a
Update objects.md
Swap76 Oct 26, 2019
b4e6eac
Merge pull request #221 from Pyro13m/master
Swap76 Oct 26, 2019
c720efa
Add info about Variables in JavaScript #197
criscros-garcia Oct 26, 2019
04dde4e
Update fs_module.md
Swap76 Oct 26, 2019
e6acc05
Merge pull request #223 from frahmadani/fs_module-docs
Swap76 Oct 26, 2019
8c71ccd
Merge pull request #224 from vlastikczech/feature/update-splice-docs
Swap76 Oct 26, 2019
0b7de97
Update timer_function.md
Swap76 Oct 26, 2019
b7d09bb
Merge pull request #225 from shahpranaf/master
Swap76 Oct 26, 2019
f406844
Delete Hoisting.js
Swap76 Oct 26, 2019
fcd3296
Add info about identifiers names restricctions
AleCentalz Oct 26, 2019
d55dfd8
Merge pull request #226 from Aman22sharma/feat-add-doc
Swap76 Oct 26, 2019
6e62c6c
Update string_operation.md
Swap76 Oct 26, 2019
043b8f2
Merge pull request #227 from ofarukcaki/patch-2
Swap76 Oct 26, 2019
4ef0882
Merge pull request #228 from WojciechPreficz/update-default-values
Swap76 Oct 26, 2019
c002e27
Merge pull request #229 from GumpFlash/master
Swap76 Oct 26, 2019
965ea61
Update express.md
Swap76 Oct 26, 2019
bd2eb2d
Merge pull request #230 from NiyongaboEric/ft-readme-destructe-js
Swap76 Oct 26, 2019
405eaf2
Merge pull request #232 from NiyongaboEric/ft-readme-express-js
Swap76 Oct 26, 2019
686331e
Update variables.md
Swap76 Oct 26, 2019
999a1da
Merge branch 'master' into add-info-about-variables
Swap76 Oct 26, 2019
6c30c9c
Merge pull request #233 from criscros-garcia/add-info-about-variables
Swap76 Oct 26, 2019
5cbdba2
Merge pull request #234 from GudeTamma/complete-info-about-variables
Swap76 Oct 26, 2019
af82499
Added documentation for Looping an Object
Surya97 Oct 26, 2019
7359553
comments added and new console logs
ferdiaz93 Oct 26, 2019
055a3bc
added explanation to arrow functions
eswong610 Oct 27, 2019
745b33c
Update looping_an_object.md
Swap76 Oct 27, 2019
1ca6109
Merge pull request #235 from Surya97/looping-object-docs
Swap76 Oct 27, 2019
89ba018
Merge pull request #236 from ferdiaz93/master
Swap76 Oct 27, 2019
bcd116f
Merge pull request #237 from eswong610/arrowfunction
Swap76 Oct 27, 2019
8d824f7
working on conditional statement
lnchapin Oct 27, 2019
39a50b5
conditional statement
lnchapin Oct 27, 2019
c527c74
finishing conditionals
lnchapin Oct 27, 2019
dc34c5b
update higher_order_functions.md
anuk79 Oct 27, 2019
3c7edcd
Update condition_statments.md
Swap76 Oct 27, 2019
ed72b63
Merge pull request #238 from lnchapin/master
Swap76 Oct 27, 2019
e1cee85
Added information on this keyword with examples
shahpranaf Oct 27, 2019
a0136de
Update this.md
Swap76 Oct 27, 2019
66b6bc8
Merge pull request #240 from shahpranaf/master
Swap76 Oct 27, 2019
c91d0ec
Styling in Object updated
Swap76 Oct 28, 2019
ed21989
Created includes.js for includes method
niyonx Oct 28, 2019
38ac790
Add exercise question for array methods in javascript
MoisesTR Oct 28, 2019
109df80
Create if_else.md
garrowp Oct 28, 2019
7b84734
Merge pull request #1 from Swap76/master
somecatdad Oct 28, 2019
63fd49a
Add object examples
somecatdad Oct 28, 2019
7048cdd
revert deleting of higher_order_functions.js
anuk79 Oct 28, 2019
89f6835
if-else question added
luweina Oct 28, 2019
6b4169f
Create looping_objects.md
Oct 28, 2019
4cfe5e1
Create higher_order_functions.md
Oct 28, 2019
20814c1
added an exercise for for-each
bharath-b06 Oct 28, 2019
e5df676
Moved solution of exercise to solutions folder
Swap76 Oct 28, 2019
8949683
Moved Solutions into Exercise
Swap76 Oct 28, 2019
ac99675
Merge pull request #250 from niyonx/patch-2
Swap76 Oct 28, 2019
5d9ae51
Merge pull request #257 from MoisesTR/array_method_exercise_question
Swap76 Oct 28, 2019
950d6a8
Merge pull request #258 from garrowp/patch-1
Swap76 Oct 28, 2019
dc0f0eb
Merge pull request #259 from sealedHuman/master
Swap76 Oct 28, 2019
b55e746
Merge pull request #239 from anuk79/edit-higher-order-functions
Swap76 Oct 28, 2019
13f1bc6
Update and rename if-else.md to if_else.md
Swap76 Oct 28, 2019
5633444
Merge branch 'master' into js-questions
Swap76 Oct 28, 2019
121f9ef
Merge pull request #260 from luweina/js-questions
Swap76 Oct 28, 2019
35648ec
Update looping_objects.md
Swap76 Oct 28, 2019
d7e5651
Merge pull request #261 from andyhu92/patch-1
Swap76 Oct 28, 2019
04e6986
Merge pull request #262 from andyhu92/patch-2
Swap76 Oct 28, 2019
f1806a1
Merge pull request #272 from bharath-b06/master
Swap76 Oct 28, 2019
dabb497
add forEach tutorial with 2 examples
Ahmed-Elbessfy Oct 28, 2019
76f6942
Moved higher order components
Swap76 Oct 28, 2019
dcca6fe
added string.md
MusaBajwa Oct 28, 2019
6edeb6f
added exercise questions
MusaBajwa Oct 28, 2019
fb0e70b
Added exercise question for bitwise operators in JS
aenkirch Oct 28, 2019
d5d683b
Merge pull request #273 from Ahmed-Elbessfy/forEach-test
Swap76 Oct 28, 2019
57f0a41
Excercise for spilce() and slice()
thakkar7 Oct 28, 2019
b887230
Merge pull request #274 from MusaBajwa/issue-270
Swap76 Oct 28, 2019
b92a029
Merge pull request #275 from aenkirch/aenkirch-bitwise-branch
Swap76 Oct 28, 2019
b93be1c
Merge pull request #280 from thakkar7/nbch
Swap76 Oct 28, 2019
8d39e0c
generators
Oct 28, 2019
56a3d6c
Add information about Classes
Oct 28, 2019
0735fc8
Fix some typos
Oct 28, 2019
2a350a3
added anagram problem
deveshp530 Oct 28, 2019
d8e3000
Create reduce.md
risc12 Oct 28, 2019
1d2e6e7
Update reduce.md
risc12 Oct 28, 2019
cfab391
Merge pull request #282 from san-kov/generators
Swap76 Oct 28, 2019
8feb3fd
Merge pull request #283 from jcespinosa/classes-issue-186
Swap76 Oct 28, 2019
6142ece
Merge pull request #284 from deveshp530/master
Swap76 Oct 28, 2019
b8f0460
Merge pull request #287 from risc12/patch-1
Swap76 Oct 28, 2019
9e5ac0e
Merge pull request #288 from risc12/patch-2
Swap76 Oct 28, 2019
08b3471
Update .gitignore
Swap76 Oct 28, 2019
295d280
Add comparison operators exercises, closes #247
lajacl Oct 28, 2019
243cdb4
(feat): Adds documentation for inheritance per issue 189
mpaarating Oct 28, 2019
ea9f2da
added exercises for switch case
Junglefuss Oct 28, 2019
3a1df4c
Added Inheritance question
l1qu1dated Oct 28, 2019
141acef
Remove emoji that isn't properly displaying
lajacl Oct 28, 2019
dd2f2fd
added math random function and math round
cee-elle Oct 28, 2019
fba8524
Add how get evironment variable
laercios Oct 29, 2019
7d3a18b
loops
lnchapin Oct 29, 2019
a0b1f49
Merge pull request #290 from lajacl/master
Swap76 Oct 29, 2019
d877b1d
Merge pull request #291 from mpaarating/issues/189-add-inheritance-ex…
Swap76 Oct 29, 2019
d7f3597
Merge pull request #293 from cryolis/issue#255
Swap76 Oct 29, 2019
2bc1966
Merge pull request #292 from Junglefuss/master
Swap76 Oct 29, 2019
12fb473
Merge pull request #295 from cee-elle/math-random-function
Swap76 Oct 29, 2019
2483748
Update loops.md
Swap76 Oct 29, 2019
8ab8da3
Merge pull request #297 from lnchapin/master
Swap76 Oct 29, 2019
9c48544
Merge pull request #296 from laercios/master
Swap76 Oct 29, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module.exports = {
"quotes": ["error", "double"],
"semi": ["error", "always"],
"eol-last": ["error", "never"],
"no-multiple-empty-lines": ["error", { max: 1 }]
"no-multiple-empty-lines": ["error", { max: 1 }],
"no-var": ["error"]
}
};
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
package-lock.json
docs/_sidebar.md
.DS_Store
44 changes: 34 additions & 10 deletions JavaScript_Advance/arrow_function.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
let a = () => {
// This is arrow function came new in ES6
//It assigns the function to variable a as the identifier with let instead and adds arrows before the curly braces.

};


let multiply = (num) => num * num

//arrow functions also works without curly braces {} and can directly write expression after the arrows
// this is known as concise body as opposed to a block body (with {});
//cannot be used with if statements, or an error will appear since it only takes one expression;
//ternary operators can be used with arrow functions as a more concise way to write if statements



let info = {
firstName: "Swapnil",
lastName: "Shinde",
getFullName: () => {
return(`My name is ${this.firstName} ${this.lastName}`); // Arrow functions don't have "this" property
return (`My name is ${this.firstName} ${this.lastName}`); // Arrow functions don't have "this" property
}
}
//not having this. binding means it also cannot be called with new and used as a constructor


console.log(info.getFullName());
// Output My name is undefined undefined that's why we don't use this with arrow function
Expand All @@ -17,7 +31,7 @@ let newInfo = {
firstName: "Swapnil",
lastName: "Shinde",
getFullName: () => {
return(`My name is ${newInfo.firstName} ${newInfo.lastName}`); // If we are using arrow function then directly use the variables as shown
return (`My name is ${newInfo.firstName} ${newInfo.lastName}`); // If we are using arrow function then directly use the variables as shown
}
}

Expand All @@ -31,32 +45,42 @@ class Student {
}

getName = () => {
return this.name;
return this.name;
}
}

console.log((new Student).getName()) // Gives error for node versions before 12.4.0(Approx) SyntaxError: Unexpected token =

class StudentInfo {

constructor (firstName,lastName, age, branch, college){
this.firstName = firstName;
constructor(firstName, lastName, age, branch, college) {
this.firstName = firstName;
this.lastName = lastName;
this.age = age;
this.age = age;
this.branch = branch;
this.college = college;
};

getFullName = () => { // Returns full name using string interpolation
return(`My name is ${this.firstName} ${this.lastName}`); // If we are using arrow function then directly use the variables as shown
return (`My name is ${this.firstName} ${this.lastName}`); // If we are using arrow function then directly use the variables as shown
};

getBranch = () => { // Returns Branch
return(this.branch);
return (this.branch);
};

}

let Swapnil = new StudentInfo("Swapnil", "Shinde",19, "Computer", "Sies"); // This way we can create new objects with arguments
let Swapnil = new StudentInfo("Swapnil", "Shinde", 19, "Computer", "Sies"); // This way we can create new objects with arguments

console.log(Swapnil.getFullName()); // Output My name is Swapnil Shinde

//settimeout without arrow function
setTimeout(function () {
console.log("hello world");
}, 1000);

console.log(Swapnil.getFullName()); // Output My name is Swapnil Shinde
//settimeout with arrow function
setTimeout(() => {
console.log("hello world");
}, 0); //arrow functions provide better readability
2 changes: 1 addition & 1 deletion JavaScript_Advance/callback.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ transformNumber(10, (num) => {
* passed to the `resolve()` function, will get passed to the function passed to `.then()`
* function. Look at the following example from MDN official documents:
*/
var p1 = new Promise((resolve, reject) => {
const p1 = new Promise((resolve, reject) => {
resolve("Success!");
// or
// reject(new Error("Error!"));
Expand Down
2 changes: 1 addition & 1 deletion JavaScript_Advance/cookies.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ console.log("Simple usage:" + document.cookie);
// #2 Get a cookie with the name 'actor'
document.cookie = "movie=Jungle Book";
document.cookie = "actor=Balu";
var cookieValue = document.cookie.replace(/(?:(?:^|.*;\s*)actor\s*\=\s*([^;]*).*$)|^.*$/, "$1");
const cookieValue = document.cookie.replace(/(?:(?:^|.*;\s*)actor\s*\=\s*([^;]*).*$)|^.*$/, "$1");
console.log("Cookie with the name 'actor':" + cookieValue);

// #3 Set cookie and execute code only once if cookie doesn't exist yet
Expand Down
2 changes: 1 addition & 1 deletion JavaScript_Advance/do_while_loop.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ do {

*/

var n = 1;
let n = 1;

do {
console.log("n is less than 6. n = " + n);
Expand Down
12 changes: 11 additions & 1 deletion JavaScript_Advance/event_loop.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,14 @@ setTimeout(() => {

console.log("Last statement"); // This statement gets printed first

// This enables the non blocking using event based management
// This enables the non blocking using event based management

console.log("a");
setTimeout(() => {
console.log("b");
}, 2000);
console.log("c");
setTimeout(() => {
console.log("d");
}, 0);
// except answer : a , c , d , b
17 changes: 16 additions & 1 deletion JavaScript_Advance/filtering_array.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,19 @@ const animals = ["cats", "dogs", "bunnies", "birds"];

const start_with_b = animals.filter(name => name.indexOf("b") === 0);

console.log(start_with_b); // ['bunnies', 'birds']
console.log(start_with_b); // ['bunnies', 'birds']

// function of filter (basic callback for filter)
const arr = [1, 3, 42, 2, 4, 5];
function filter (array, callback) {
const callback_list = [];
for (const i of array) {
callback_list.push(callback(i));
}
return callback_list;
}
// modifyable callback function
function callback (num) {
return Math.pow(num, 2);
}
console.log(filter(arr, callback));
30 changes: 30 additions & 0 deletions JavaScript_Advance/generators.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
Generators are functions with the possibility of exit and subsequent entry.
Their execution context (variable values) is preserved on subsequent inputs.
*/

// Let's consider a simple example:
function* myGenerator() {
yield 5
yield 6
}

// In the example above, we wrote a simple generator function with asteriks(*) notation.
// Next to the yield we put values that are going to be extracted from the function
// In order to extract them one by one, we should at first call myGenerator function

const gen = myGenerator()

// The returning value of myGenerator function is a object-iterator. It has next() method
// Which we may call to get the current generator function value:

gen.next().value // 5

// We get the value field of 'next' method's returning value, wich is an object as well
// Let's call this again in order to get the next value:

gen.next().value // 6

// After we iterate through all the values, the next value is going to be undefined.

gen.next().value // undefined.
7 changes: 7 additions & 0 deletions JavaScript_Advance/get_environment_variable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Getting values of environment variables
// For example, getting username of machine
const ENV_VARIABLE_KEY = "USER";

const ENV_VARIABLE_VALUE = process.env[ENV_VARIABLE_KEY];

console.log(ENV_VARIABLE_VALUE);
8 changes: 7 additions & 1 deletion JavaScript_Advance/hoisting.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,10 @@ elem.innerHTML = x; // Display x in the element
/* Conclusion :Example 1 gives the same result as Example 2
so, Hoisting is JavaScript's default behavior of moving all declarations to the top of the current scope
(to the top of the current script or the current function)
*/
*/

console.log(foo);
const foo = "foo"; // unable to print due to the hoisting behaviour

console.log(ok);
var ok = "this is printing";// var is hoisted
25 changes: 23 additions & 2 deletions JavaScript_Advance/promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ getAsyncDataWithPromises()
.then(data => {
// ... use data
}).catch(e => {
// ... handle exception
// ... handle exception
});

// promises promise the nodejs main thread that i'm going to come after doing a particular task
Expand Down Expand Up @@ -77,4 +77,25 @@ asyncCall
// appended with ' bar' to become 'foo bar'
.then(val => `${val} bar`)
// console logs 'foo bar'
.then(console.log);
.then(console.log);

// promise.all();\
const fs = require("fs");
const dir = __dirname + "/text/";
const promisesarray = ["Text file content start after this : "];
function readfile () {
fs.readdir(dir, "utf-8", (err, File) => {
File.forEach(file => {
promisesarray.push(new Promise((resolve, reject) => {
fs.readFile(dir + file, "utf-8", (err, data) => {
if (err) reject(err);
else resolve(data);
});
}));
});
Promise.all(promisesarray).then(data => {
console.log(data);
});
});
}
readfile();
32 changes: 32 additions & 0 deletions JavaScript_Advance/recursion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Recursion is when a function calls itself.
// Recursion gives us an interesting way to write algorithms that can solve complicated problems.

// Take for example factorials which is just an integer times each of the integers below it: so 5 factorial (also written 5!) is just 5 * 4 * 3 * 2 * 1.
// If we want to write an algorithm that can calculate the factorial of any given number without using recursion, we could do something like this:

function calcuateFactorialWithoutRecursion (num) {
let total = num;
let nextNumber = num - 1;
while (nextNumber >= 1) {
total = total * nextNumber;
nextNumber--; // decrease the next number by 1
}
return total;
}

// calcuateFactorialWithoutRecursion(5) // 120
// 5 * 4 * 3 * 2 * 1 = 120

// We can write the same function this way using recursion:
function calculateFactorialWithRecursion (num) {
if (num === 1) { // This step is critical. The num parameter will keep decreasing until it gets to 1.
// Once the function gets called with 1 as a parameter, the function will return without calling itself.
return num;
}
return num * calculateFactorialWithRecursion(num - 1);
}

calculateFactorialWithRecursion(7); // 5040
// 7 * 6 * 5 * 4 * 3 * 2 * 1 = 5040

// See how clean recursion made this algorithm!
8 changes: 4 additions & 4 deletions JavaScript_Advance/timer_functions.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
// setTimeout setInterval in both functions the time is specified in millisecond

// setTimeout This runs a code after given time starting form calling this method in program.
// setTimeout This runs a code after given time starting from calling this method in program.

setTimeout(() => {
console.log("SetTimeout is Called");
console.log("SetTimeout is Called");
}, 5000); // This will print SetTimeout is Called after 5sec after calling it

// For stopping this we can use ClearTimeout

// setInterval This runs a code after specific interval of time till we stop the timer.

starting = setInterval(() => {
console.log("SetInterval is Called");
console.log("SetInterval is Called");
}, 3000); // This will print setInterval is Called after every 3sec

// We can stop the interval and timeout using clearTimeout and clearInterval
setTimeout(() => {
clearInterval(starting);
clearInterval(starting);
}, 7000);

// Output of this whole program is
Expand Down
9 changes: 7 additions & 2 deletions JavaScript_Advance/while_loop.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@

*/

var n = 1;
let n = 1;

while (n < 6) {
console.log("n is less than 6. n = " + n);
n++;
}
}

let sum = 1;
do {
console.log(`sum now is ${sum++}`);
} while (sum <= 100);
3 changes: 3 additions & 0 deletions JavaScript_Basics/Datatypes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
var length = 16; // Number
var lastName = "Johnson"; // String
var x = { firstName: "John", lastName: "Doe" }; // Object
10 changes: 5 additions & 5 deletions JavaScript_Basics/arrays.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,26 @@ console.log(easyMethod);
// Output [ 'Swapnil Satish Shinde', 76, true ]

// The pop() method removes the last element from an array:
var fruits = ["Banana", "Orange", "Apple", "Mango"];
const fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.pop(); // Removes the last element ("Mango") from fruits and output is ["Banana","Orange","Apple"]

// Shifting is equivalent to popping, working on the first element instead of the last.
// The shift() method removes the first array element and "shifts" all other elements to a lower index.
var cars = ["Acura", "Audi", "Bugatti", "Honda"];
const cars = ["Acura", "Audi", "Bugatti", "Honda"];
cars.shift(); // Removes the first element ("Acura") from cars and output is ["Audi","Bugatti","Honda"]

// The length property provides an easy way to append a new element to an array:
var mobiles = ["Apple", "Nokia", "Samsung", "Sony"];
const mobiles = ["Apple", "Nokia", "Samsung", "Sony"];
mobiles[mobiles.length] = "HTC"; // Appends "HTC" to mobiles and output is ["Apple", "Nokia", "Samsung", "Sony", "HTC"]

// delete will delete the object property, but will not reindex the array or update its length. This makes it appears as if it is undefined:
var myArray = ["a", "b", "c", "d"];
const myArray = ["a", "b", "c", "d"];
delete myArray[0];
"The first value is: " + myArray[0]; // The first value is: undefined
// Using delete may leave undefined holes in the array. Use pop() or shift() instead.

// The splice() method removes items from array and/or adds items to array and returns the removed items:
var names = ["Anne", "Belle", "Chloe", "Diane", "Ella", "Frances"];
const names = ["Anne", "Belle", "Chloe", "Diane", "Ella", "Frances"];
names.splice(4, 1);
// This removes 1 item from index 4
// returns "Ella"
Expand Down
4 changes: 2 additions & 2 deletions JavaScript_Basics/bugs.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
var obj = {
const obj = {
name: "Some name"
};

var name = null;
const name = null;

console.log(typeof obj); // object;
console.log(typeof name); // object;
Loading