Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [JavaScript]Wywołanie funkcji.
MeGusta
post 10.08.2016, 14:18:14
Post #1





Grupa: Zarejestrowani
Postów: 155
Pomógł: 0
Dołączył: 6.07.2015

Ostrzeżenie: (10%)
X----


Witam, pytanie głupie ale nie mam pojęcia jak wywołać funkcję start.

  1. var game = function() {
  2.  
  3. this.start = function () {
  4.  
  5. console.log ('Game started');
  6.  
  7. };
  8.  
  9. };
  10.  
  11. // próbowałem
  12.  
  13. game.start();
  14. this.start();
  15.  


Ten post edytował MeGusta 10.08.2016, 14:18:35
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 2)
markuz
post 10.08.2016, 14:20:48
Post #2





Grupa: Zarejestrowani
Postów: 1 240
Pomógł: 278
Dołączył: 11.03.2008

Ostrzeżenie: (0%)
-----


[JAVASCRIPT] pobierz, plaintext
  1. var game = {
  2. start: function() {
  3. console.log('game.start');
  4. }
  5. };
  6.  
  7. game.start();
  8.  
  9. var Game = function() {
  10. this.start = function() {
  11. console.log('Game.start');
  12. }
  13. }
  14.  
  15. var g = new Game();
  16. g.start();
[JAVASCRIPT] pobierz, plaintext


--------------------
Go to the top of the page
+Quote Post
viking
post 10.08.2016, 14:42:18
Post #3





Grupa: Zarejestrowani
Postów: 6 380
Pomógł: 1116
Dołączył: 30.08.2006

Ostrzeżenie: (0%)
-----


Albo w ES6

  1. class game {
  2. start() {
  3. console.log ('Game started');
  4. }
  5. }
  6.  
  7. let game1 = new game();
  8. game1.start();




--------------------
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 14.08.2025 - 07:33