Files
2023-12-20 18:21:47 -05:00

11 KiB

In [15]:
let date = new Date()
In [16]:
date.toGMTString()
Out [16]:
"Fri, 15 Dec 2023 23:27:35 GMT"
In [17]:
date.getTimezoneOffset()
Out [17]:
300
In [18]:
let url = new URL("http://example.com/notebooks/Untitled.ipynb");
In [23]:
url.hostname = "google.com"
Out [23]:
"google.com"
In [24]:
url.toString()
Out [24]:
"http://google.com/notebooks/Untitled.ipynb"
In [25]:
let url2 = new URL("https://fr.wikipedia.org/wiki/Programmation_orient%C3%A9e_objet");
In [26]:
url2.pathname
Out [26]:
"/wiki/Programmation_orient%C3%A9e_objet"
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))
125
In [45]:
let person = new Person("steve", "boutin", 1975, "burundi");
Stack trace:
ReferenceError: Person is not defined
    at <anonymous>:1:35
In [47]:
if(person.isMajor()){}
Stack trace:
TypeError: person.isMajor is not a function
    at <anonymous>:1:33
In [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]:
"Sun, 09 Oct 1983 04:00:00 GMT"
In [75]:
new Date("Sun, 09 Oct 1983 04:00:00 GMT")
Out [75]:
1983-10-09T04:00:00.000Z
In [77]:
dateOfBirth.toISOString()
Out [77]:
"1983-10-09T04:00:00.000Z"
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());
62
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]: