mirror of
https://github.com/Cametendo/EMVs-Creative-coding.git
synced 2026-06-20 17:45:02 +02:00
Added some things
This commit is contained in:
10
Week-3/import-export/borderpatrol.html
Normal file
10
Week-3/import-export/borderpatrol.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Document</title>
|
||||
<script type="module" src="main.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
...
|
||||
</body>
|
||||
</html>
|
||||
22
Week-3/import-export/directExport.js
Normal file
22
Week-3/import-export/directExport.js
Normal file
@@ -0,0 +1,22 @@
|
||||
export const someString = "just a string";
|
||||
export const someNumber = 2;
|
||||
export const someObject = {
|
||||
name: "Oger",
|
||||
rank: 1,
|
||||
title: "Oger",
|
||||
class: "Beast",
|
||||
race: "Oger",
|
||||
};
|
||||
|
||||
export function normalFunction() {
|
||||
console.log("nomral function!");
|
||||
}
|
||||
|
||||
export const arrowFunction = () => console.log("arrow function!");
|
||||
|
||||
export class SomePeron {
|
||||
constructor(name, age) {
|
||||
this.name = name;
|
||||
this.age = age;
|
||||
}
|
||||
}
|
||||
47
Week-3/import-export/main.js
Normal file
47
Week-3/import-export/main.js
Normal file
@@ -0,0 +1,47 @@
|
||||
import { printMood, printName } from "./student-Object.js";
|
||||
|
||||
const myStudent1 = { name: "Sven", mood: "Ruffy" };
|
||||
|
||||
console.log("myStudent:", myStudent1);
|
||||
printName(myStudent1);
|
||||
printMood(myStudent1);
|
||||
|
||||
/*
|
||||
import Student, {
|
||||
printMood as printngMood,
|
||||
printName as printngName,
|
||||
} from "./student-Class.js";
|
||||
|
||||
const myStudent2 = new Student("Juerg", "Wanted");
|
||||
|
||||
console.log("myStudent:", myStudent);
|
||||
printingName(myStudent2);
|
||||
printingMood(myStudent2);
|
||||
*/
|
||||
|
||||
import Student, {
|
||||
printMood as renameFunction,
|
||||
printName as printedName,
|
||||
} from "./student-Class.js";
|
||||
|
||||
const myStudent = new Student("Nika", "God");
|
||||
|
||||
console.log("myStudent:", myStudent);
|
||||
printedName(myStudent);
|
||||
renameFunction(myStudent);
|
||||
|
||||
import {
|
||||
SomePeron,
|
||||
arrowFunction,
|
||||
normalFunction,
|
||||
someNumber,
|
||||
someObject,
|
||||
someString,
|
||||
} from "./directExport.js";
|
||||
|
||||
console.log(new SomePeron("someName", 22));
|
||||
arrowFunction();
|
||||
normalFunction();
|
||||
console.log(someNumber);
|
||||
console.log(someObject);
|
||||
console.log(someString);
|
||||
20
Week-3/import-export/student-Class.js
Normal file
20
Week-3/import-export/student-Class.js
Normal file
@@ -0,0 +1,20 @@
|
||||
class Student {
|
||||
constructor(name, mood) {
|
||||
this.name = name;
|
||||
this.mood = mood;
|
||||
}
|
||||
}
|
||||
|
||||
function printName(student) {
|
||||
console.log(`Student's name is: ${student.name}`);
|
||||
}
|
||||
|
||||
const printMood = (student) => console.log(`Student's mood is ${student.mood}`);
|
||||
|
||||
//Multiline:
|
||||
export default Student;
|
||||
export { printName }; // export { printName as displayName };
|
||||
export { printMood }; // export { printName as displayMood };
|
||||
|
||||
// Or one liner (Only one export works though):
|
||||
// export { Student as default, printName, printMood };
|
||||
19
Week-3/import-export/student-Object.js
Normal file
19
Week-3/import-export/student-Object.js
Normal file
@@ -0,0 +1,19 @@
|
||||
function printName(student) {
|
||||
console.log(`Student's name is: ${student.name}`);
|
||||
}
|
||||
|
||||
const printMood = (student) => console.log(`Student's mood is $(student.mood)`);
|
||||
|
||||
// Multiline
|
||||
export { printName };
|
||||
export { printMood };
|
||||
|
||||
//Or one liner (Only one export works though):
|
||||
// export { printName, printMood };
|
||||
/*
|
||||
export {
|
||||
Student as default,
|
||||
printName as displayName,
|
||||
printMood as displayMood,
|
||||
};
|
||||
*/
|
||||
Reference in New Issue
Block a user