534 lines
11 KiB
Plaintext
534 lines
11 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 15,
|
|
"id": "6ea9db8b-018f-4766-a107-9ba7c20848f2",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"let date = new Date()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 16,
|
|
"id": "4aba8fd3-acb6-4473-b960-a5aa7f370320",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"\u001b[32m\"Fri, 15 Dec 2023 23:27:35 GMT\"\u001b[39m"
|
|
]
|
|
},
|
|
"execution_count": 16,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"date.toGMTString()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 17,
|
|
"id": "9b50f1ad-46d3-44ef-9afe-d8be15772c4a",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"\u001b[33m300\u001b[39m"
|
|
]
|
|
},
|
|
"execution_count": 17,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"date.getTimezoneOffset()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 18,
|
|
"id": "120697ff-9f7f-49fd-b3ef-c48e0fc6f758",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"let url = new URL(\"http://example.com/notebooks/Untitled.ipynb\");"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 23,
|
|
"id": "f0a4c569-b076-4441-aedc-60477fdaf4c2",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"\u001b[32m\"google.com\"\u001b[39m"
|
|
]
|
|
},
|
|
"execution_count": 23,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"url.hostname = \"google.com\""
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 24,
|
|
"id": "c47ef44a-ae85-4654-8345-b8528ac7e253",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"\u001b[32m\"http://google.com/notebooks/Untitled.ipynb\"\u001b[39m"
|
|
]
|
|
},
|
|
"execution_count": 24,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"url.toString()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 25,
|
|
"id": "26e99472-5c7c-44fd-99bf-d0db5ac89708",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"let url2 = new URL(\"https://fr.wikipedia.org/wiki/Programmation_orient%C3%A9e_objet\");"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 26,
|
|
"id": "de1aedbd-d21a-48d2-a258-df99847c4622",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"\u001b[32m\"/wiki/Programmation_orient%C3%A9e_objet\"\u001b[39m"
|
|
]
|
|
},
|
|
"execution_count": 26,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"url2.pathname"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 27,
|
|
"id": "e01d4caf-de65-4638-8992-e94d36553953",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"let person = {\n",
|
|
" name: \"didier\"\n",
|
|
"}"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 30,
|
|
"id": "306cd832-963a-4a9e-9eaa-f6a4510b9ac2",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"function sayHello(){\n",
|
|
" console.log(\"hello world\");\n",
|
|
"}"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 43,
|
|
"id": "ccdf4b55-c2f3-48ee-b821-d8e094c6e006",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"class Adder{\n",
|
|
" value;\n",
|
|
"\n",
|
|
" constructor(value){\n",
|
|
" this.value = value;\n",
|
|
" }\n",
|
|
" \n",
|
|
"\n",
|
|
" add(a){\n",
|
|
" return a + this.value;\n",
|
|
" }\n",
|
|
" \n",
|
|
"}"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 44,
|
|
"id": "0fcbba8c-f16e-4272-96bf-94de14e3388a",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\u001b[33m125\u001b[39m\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"toto = new Adder(100)\n",
|
|
"console.log(toto.add(25))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 45,
|
|
"id": "5a248f9d-893b-49d0-9806-cf281e6ee63f",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"ename": "ReferenceError",
|
|
"evalue": "Person is not defined",
|
|
"output_type": "error",
|
|
"traceback": [
|
|
"Stack trace:",
|
|
"ReferenceError: Person is not defined",
|
|
" at <anonymous>:1:35"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"let person = new Person(\"steve\", \"boutin\", 1975, \"burundi\");"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 47,
|
|
"id": "b0fd3f3d-cbf3-44e2-9ff7-fab252746cc1",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"ename": "TypeError",
|
|
"evalue": "person.isMajor is not a function",
|
|
"output_type": "error",
|
|
"traceback": [
|
|
"Stack trace:",
|
|
"TypeError: person.isMajor is not a function",
|
|
" at <anonymous>:1:33"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"if(person.isMajor()){}"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 51,
|
|
"id": "cbb202ee-fa5b-4955-a686-c23397ee45ce",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import {HockeyGame} from \"https://cdn.jsdelivr.net/gh/didiercrunch/cours-420-301-ah@006.3/modules-examples/mod.js\";\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 64,
|
|
"id": "5f9a1f61-9e4e-4747-9297-1cf9c02c8918",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"let game1 = new HockeyGame();\n",
|
|
"let game2 = new HockeyGame();\n",
|
|
"let game3 = new HockeyGame();\n",
|
|
"\n",
|
|
"function printScore(game){\n",
|
|
" console.log(`Home ${game.home} - Away ${game.away}`)\n",
|
|
"}\n",
|
|
"\n",
|
|
"function printScores(game1, game2, game3){\n",
|
|
" console.log(`Game 1: Home ${game1.home} - Away ${game1.away}`);\n",
|
|
" console.log(`Game 2: Home ${game2.home} - Away ${game2.away}`);\n",
|
|
" console.log(`Game 3: Home ${game3.home} - Away ${game3.away}`);\n",
|
|
"}"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 65,
|
|
"id": "628f8ad5-f8eb-48f9-bc80-cb2db3fd9de7",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"game1.homeTeamScores()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 66,
|
|
"id": "44ab673f-7d0b-4095-a1f5-e8cbe35fbb31",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"Game 1: Home 1 - Away 0\n",
|
|
"Game 2: Home 0 - Away 0\n",
|
|
"Game 3: Home 0 - Away 0\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"printScores(game1, game2, game3)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 67,
|
|
"id": "734050a1-f28d-44a3-8077-39df1295e1fa",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"game3.awayTeamScores()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 68,
|
|
"id": "13d32e62-091e-4706-9d62-c582211e9408",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"Game 1: Home 1 - Away 0\n",
|
|
"Game 2: Home 0 - Away 0\n",
|
|
"Game 3: Home 0 - Away 1\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"printScores(game1, game2, game3)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 69,
|
|
"id": "c27e6ab3-b4f3-46b8-b6f6-ce87883a45dc",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import {HockeyPlayer} from \"https://cdn.jsdelivr.net/gh/didiercrunch/cours-420-301-ah@006.1/modules-examples/mod.js\";\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 70,
|
|
"id": "6f131f34-8d45-4d82-a9a5-5dbfdd99d4a8",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"let dateOfBirth = new Date(1983, 9, 9);\n",
|
|
"let player = new HockeyPlayer(\"didier\", \"amyot\", dateOfBirth)\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 73,
|
|
"id": "ab87ba0a-26e8-448e-a953-9fe4546dd9b8",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"\u001b[32m\"Sun, 09 Oct 1983 04:00:00 GMT\"\u001b[39m"
|
|
]
|
|
},
|
|
"execution_count": 73,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"dateOfBirth.toUTCString()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 75,
|
|
"id": "7e50ce6e-90e8-42ee-90e2-ef5c882d84f1",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"\u001b[35m1983-10-09T04:00:00.000Z\u001b[39m"
|
|
]
|
|
},
|
|
"execution_count": 75,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"new Date(\"Sun, 09 Oct 1983 04:00:00 GMT\")"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 77,
|
|
"id": "4acfd4c6-a432-4b3d-a05a-69f4bdc6c8ff",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"\u001b[32m\"1983-10-09T04:00:00.000Z\"\u001b[39m"
|
|
]
|
|
},
|
|
"execution_count": 77,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"dateOfBirth.toISOString()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 2,
|
|
"id": "908117c5-d6e1-4c0c-9c1f-a5b9e4b44f11",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\u001b[33m62\u001b[39m\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"\n",
|
|
"import {HockeyPlayer, HockeyPlayerStatistics} \n",
|
|
" from \"https://cdn.jsdelivr.net/gh/didiercrunch/cours-420-301-ah@006.3/modules-examples/mod.js\";\n",
|
|
"\n",
|
|
"let wayneGretzky = new HockeyPlayer(\"Wayne\", \n",
|
|
" \"Gretzky\", \n",
|
|
" new Date(1961, 0, 26));\n",
|
|
"\n",
|
|
"let wayneGretzkyStats = new HockeyPlayerStatistics(\"Wayne\", \n",
|
|
" \"Gretzky\", \n",
|
|
" new Date(1961, 0, 26));\n",
|
|
"\n",
|
|
"console.log(wayneGretzky.currentAge());"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "b05528d2-2c8e-4e91-afff-bb50d0bc6fd8",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "2afca106-0957-4dfb-832c-31a12695704a",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "995a3e03-fa7b-48fb-a1bf-28e0eddb7d34",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "457c74d2-138d-42c4-8d60-454a10a266c3",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "c9d0aa08-3bc0-44e0-a1e4-030a6c620b5a",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "b24755d6-4405-46c5-ba57-2f4231541446",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "3c0691b1-6406-460d-ac8c-c23d4b29b72a",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "36abe78f-c35d-4d1c-b569-32aba406199c",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Deno",
|
|
"language": "typescript",
|
|
"name": "deno"
|
|
},
|
|
"language_info": {
|
|
"file_extension": ".ts",
|
|
"mimetype": "text/x.typescript",
|
|
"name": "typescript",
|
|
"nb_converter": "script",
|
|
"pygments_lexer": "typescript",
|
|
"version": "5.2.2"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|