11 KiB
11 KiB
In [15]:
let date = new Date()In [16]:
date.toGMTString()Out [16]:
[32m"Fri, 15 Dec 2023 23:27:35 GMT"[39m
In [17]:
date.getTimezoneOffset()Out [17]:
[33m300[39m
In [18]:
let url = new URL("http://example.com/notebooks/Untitled.ipynb");In [23]:
url.hostname = "google.com"Out [23]:
[32m"google.com"[39m
In [24]:
url.toString()Out [24]:
[32m"http://google.com/notebooks/Untitled.ipynb"[39m
In [25]:
let url2 = new URL("https://fr.wikipedia.org/wiki/Programmation_orient%C3%A9e_objet");In [26]:
url2.pathnameOut [26]:
[32m"/wiki/Programmation_orient%C3%A9e_objet"[39m
In [27]:
let person = {
name: "didier"
}In [30]:
function sayHello(){
console.log("hello world");
}In [43]:
class Adder{
value;
constructor(value){
this.value = value;
}
add(a){
return a + this.value;
}
}In [44]:
toto = new Adder(100)
console.log(toto.add(25))[33m125[39m
In [45]:
let person = new Person("steve", "boutin", 1975, "burundi");Stack trace:
ReferenceError: Person is not defined
at <anonymous>:1:35In [47]:
if(person.isMajor()){}Stack trace:
TypeError: person.isMajor is not a function
at <anonymous>:1:33In [51]:
import {HockeyGame} from "https://cdn.jsdelivr.net/gh/didiercrunch/cours-420-301-ah@006.3/modules-examples/mod.js";
In [64]:
let game1 = new HockeyGame();
let game2 = new HockeyGame();
let game3 = new HockeyGame();
function printScore(game){
console.log(`Home ${game.home} - Away ${game.away}`)
}
function printScores(game1, game2, game3){
console.log(`Game 1: Home ${game1.home} - Away ${game1.away}`);
console.log(`Game 2: Home ${game2.home} - Away ${game2.away}`);
console.log(`Game 3: Home ${game3.home} - Away ${game3.away}`);
}In [65]:
game1.homeTeamScores()In [66]:
printScores(game1, game2, game3)Game 1: Home 1 - Away 0 Game 2: Home 0 - Away 0 Game 3: Home 0 - Away 0
In [67]:
game3.awayTeamScores()In [68]:
printScores(game1, game2, game3)Game 1: Home 1 - Away 0 Game 2: Home 0 - Away 0 Game 3: Home 0 - Away 1
In [69]:
import {HockeyPlayer} from "https://cdn.jsdelivr.net/gh/didiercrunch/cours-420-301-ah@006.1/modules-examples/mod.js";
In [70]:
let dateOfBirth = new Date(1983, 9, 9);
let player = new HockeyPlayer("didier", "amyot", dateOfBirth)
In [73]:
dateOfBirth.toUTCString()Out [73]:
[32m"Sun, 09 Oct 1983 04:00:00 GMT"[39m
In [75]:
new Date("Sun, 09 Oct 1983 04:00:00 GMT")Out [75]:
[35m1983-10-09T04:00:00.000Z[39m
In [77]:
dateOfBirth.toISOString()Out [77]:
[32m"1983-10-09T04:00:00.000Z"[39m
In [2]:
import {HockeyPlayer, HockeyPlayerStatistics}
from "https://cdn.jsdelivr.net/gh/didiercrunch/cours-420-301-ah@006.3/modules-examples/mod.js";
let wayneGretzky = new HockeyPlayer("Wayne",
"Gretzky",
new Date(1961, 0, 26));
let wayneGretzkyStats = new HockeyPlayerStatistics("Wayne",
"Gretzky",
new Date(1961, 0, 26));
console.log(wayneGretzky.currentAge());[33m62[39m
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]: