Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the unlimited-elements-for-elementor domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/webvol14/vu/qf8s3px08ysu520/taraba.in.rs/public_html/wp-includes/functions.php on line 6121

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the reviews-feed domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/webvol14/vu/qf8s3px08ysu520/taraba.in.rs/public_html/wp-includes/functions.php on line 6121

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the feeds-for-youtube domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/webvol14/vu/qf8s3px08ysu520/taraba.in.rs/public_html/wp-includes/functions.php on line 6121

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the google-analytics-for-wordpress domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/webvol14/vu/qf8s3px08ysu520/taraba.in.rs/public_html/wp-includes/functions.php on line 6121

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the instagram-feed domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/webvol14/vu/qf8s3px08ysu520/taraba.in.rs/public_html/wp-includes/functions.php on line 6121
Uvod u JavaScript: Prvi koraci u programiranju - TARABA HASHTAG

Uvod u JavaScript: Prvi koraci u programiranju

JavaScript je jedan od najpopularnijih programskih jezika na svetu i ključan alat za izradu modernih veb sajtova i aplikacija. Ako želite da naučite kako da dodate interaktivnost svojoj veb stranici, JavaScript je pravi izbor.

Šta je JavaScript?

JavaScript (JS) je skriptni jezik koji omogućava dodavanje dinamičkog sadržaja na veb stranice. Omogućava interakciju korisnika sa sajtom, manipulaciju HTML i CSS elementima, slanje podataka na server i još mnogo toga.

Osnovna sintaksa JavaScripta

JavaScript je relativno jednostavan za početak, a sledeći primer prikazuje kako možete ispisati tekst u konzolu:

console.log("Zdravo, svete!");

Ova linija koda će ispisati poruku “Zdravo, svet!” u konzoli pregledača.

Uključivanje JavaScripta u HTML stranicu

JavaScript možete dodati u HTML na dva načina:

  1. Unutar <script> taga u HTML datoteci:
<!DOCTYPE html>
<html>
<head>
    <title>Moja prva JS stranica</title>
</head>
<body>
    <script>
        alert("Dobrodošli na moju stranicu!");
    </script>
</body>
</html>
  1. Spoljašnja datoteka (preporučena praksa):

Napravite datoteku script.js i dodajte sledeći kod:

alert("Dobrodošli na moju stranicu!");

Zatim u HTML-u dodajte:

<script src="script.js"></script>

Osnovni koncepti JavaScripta

1. Varijable

Varijable služe za čuvanje podataka. U JavaScriptu se koriste var, let i const:

let ime = "Marko";
const godine = 25;
var grad = "Beograd";
console.log(ime, godine, grad);

2. Tipovi podataka

JavaScript podržava različite tipove podataka, uključujući:

  • String (tekst) – "Zdravo"
  • Number (brojevi) – 42, 3.14
  • Boolean (tačno/netačno) – true, false
  • Null (prazna vrednost) – null
  • Undefined (neodređeno) – undefined

3. Funkcije

Funkcije omogućavaju ponovno korišćenje koda:

function pozdrav(ime) {
    return "Zdravo, " + ime + "!";
}

console.log(pozdrav("Marko"));

4. Petlje i uslovi

Petlje i uslovi omogućavaju kontrolu toka programa:

let broj = 10;
if (broj > 5) {
    console.log("Broj je veći od 5");
} else {
    console.log("Broj je manji ili jednak 5");
}

Petlja for primer:

for (let i = 0; i < 5; i++) {
    console.log("Broj: " + i);
}

Zaključak

Ovo su samo osnovni koncepti JavaScripta. U narednim lekcijama naučićete kako da manipulišete HTML-om, obrađujete događaje, radite sa objektima i koristite moderne JavaScript funkcionalnosti poput ES6 sintakse.

Sada kada ste savladali osnove, vreme je da počnete eksperimentisati i pisati svoj kod!

Facebook Comments

Leave a Reply

Your email address will not be published. Required fields are marked *