Skip to content

Commit

Permalink
add repeat_lesson-5_JS
Browse files Browse the repository at this point in the history
  • Loading branch information
Sasha-Makar committed Jan 24, 2024
1 parent e36ee75 commit 4221054
Show file tree
Hide file tree
Showing 2 changed files with 144 additions and 0 deletions.
13 changes: 13 additions & 0 deletions JS_LESSONS/LESSONS/lesson_5/repeat/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>repeat_lesson_5</title>
</head>
<body>


<script src="main.js"></script>

</body>
</html>
131 changes: 131 additions & 0 deletions JS_LESSONS/LESSONS/lesson_5/repeat/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
// alert(22);

// function foo() {
// console.log('qwe');
// }
// foo();


// foo();
// function foo() {
// console.log('qwe');
// }


// foobar();
// let foobar = function () {
// console.log('asdfgghjjk');
// }

// let foobar = function () {
// console.log('asdfgghjjk');
// }
// foobar();
//
//
//
//
//
// let calc = function (a,b) {
// return a+ +b;
// }
// let res = calc(10, 20);
// console.log(res);
//
//
// let calculator = (a,b)=> a + b;
//
// let result = calculator(1, 2);
// console.log(result);


//
// let foobar = (...rest)=> console.log(rest);
// foobar(1, 2, 3);
//
//
// let foo = ()=> console.log(arguments);
// foo(1,2,3);

//fn declaration & fn expression __ arguments +
// fn arrow __ arguments -

// ...rest (rest arguments)___works in all fn



function foo() {
console.log('hi');
}
let x = function () {
console.log('hello');
}


let fnArr = [foo, x, z = () => console.log('aloha')];

fnArr[0]();
fnArr[1]();
fnArr[2]();

console.log('--------------');


let user = {
name: 'kokos',
age: 31,
greeting : function () {
console.log('hello my friends');
}
}
user.greeting();

let user2 = {
name: 'kokos',
age: 31,
greeting() {
console.log('hello, my name is - ' + this.name);
}
}
user2.greeting();


let user3 = {
name: 'kokos',
age: 31,
greeting : ()=> {
console.log('aloha, my name is - ' + user3.name);
}
}
user3.greeting();



let user4 = {
name: 'kokos',
age: 31,
greeting : function () {
console.log('hello');
},
wife : {
name: 'qweasdz',
greeting(){
console.log('hi, my name is - ' + this.name);
user.greeting();
}
}
}

user4.wife.greeting();


console.log('------------------');


let loop = (arr)=>{
for (const arrElement of arr) {
console.log(arrElement);
}
}

loop([1, 2, 3]);

0 comments on commit 4221054

Please sign in to comment.