Einführung JavaScript-Funktion console.log() mit Beispielen

Blog

Einführung JavaScript-Funktion console.log() mit Beispielen

Die console.log() ist eine Funktion in JavaScript, die verwendet wird, um jede Art von zuvor darin definierten Variablen oder einfach jede Nachricht zu drucken, die dem Benutzer angezeigt werden muss.



Syntax

console.log(X);

Parameter

  • Es akzeptiert einen Parameter, der ein Array, ein Objekt oder eine beliebige Nachricht sein kann.

Rückgabewert

  • Es gibt den Wert des angegebenen Parameters zurück.

JavaScript console.log() mit Beispiel

Beispiel 1

Eine Variable in die JavaScript-Konsole drucken






console.log('Selam','Poftut.com') //Output will be Selam Poftut.com sitename='poftut.com'; console.log(sitename); //Output will be poftut.com username='ismail'; console.log(username); //Output will be ismail age=35; exist=false; console.log(age); //Output will be 35 console.log(exist); //Output will be false

Ausgabe



Python-Bibliothek für maschinelles Lernen

Das ist der Bildtitel



Beispiel 2

String in die JavaScript-Konsole drucken






console.log('poftut.com'); //Otput will be poftut.com console.log('poftut.com','ismail baydan'); //Otput will be poftut.com ismail baydan console.log('poftut.com','ismail baydan','ahmet ali'); //Otput will be poftut.com ismail baydan ahmet ali console.log('poftut.com','ismail baydan','ahmet ali','Elif ecrin'); //Otput will be poftut.com ismail baydan ahmet ali Elif ecrin console.log('poftut.com','ismail baydan','ahmet ali',9); //Otput will be poftut.com ismail baydan ahmet ali 9

Ausgabe

Wo kann man axion kaufen

Das ist der Bildtitel

Beispiel 3

Zahl/Ganzzahl in die JavaScript-Konsole drucken

console.log() //Output will be 0 console.log(10) //Output will be 10 console.log(101) //Output will be 101 console.log(101.5) //Output will be 101.5 console.log(-101.5) //Output will be -101.5 console.log(-101.5987654321) //Output will be -101.5987654321 console.log(-101.5987654321123456789) //Output will be -101.59876543211234

Ausgabe

nvm-Switch-Knotenversion

Das ist der Bildtitel

Beispiel 4

Char in die JavaScript-Konsole drucken
String-Variablen bestehen aus Zeichen, wobei sie als Zeichendatentyp dargestellt werden. Wir können die Zeichen auch wie unten an die Browserkonsole ausgeben.

console.log('i') //Output will be i console.log('i','s'); //Output will be i s console.log('i','s','m'); //Output will be i s m console.log('i','s','m','a'); //Output will be i s m a console.log('i','s','m','a','i'); //Output will be i s m a i console.log('i','s','m','a','i','l'); //Output will be i s m a i l

Ausgabe

Das ist der Bildtitel

Beispiel 5

Array in der JavaScript-Konsole drucken

Arrays werden verwendet, um mehrere Werte wie eine Liste zu speichern. Wir können den Array-Inhalt auch mit der Funktion console.log() an die Browserkonsole ausgeben. Die Array-Elemente können vom gleichen Typ von unterschiedlichen Typen sein.

names=['ismail']; console.log(names); //Output will be ['ismail'] names=['ismail','elif']; console.log(names); //Output will be ['ismail', 'elif'] names=['ismail','elif','ahmet']; console.log(names); //Output will be ['ismail', 'elif', 'ahmet'] numbers=[1,2,3,4]; console.log(numbers); //Output will be [1, 2, 3, 4] myarr=['ismail','ahmet',1,2,3]; console.log(myarr); //Output will be ['ismail', 'ahmet', 1, 2, 3]

Ausgabe

kohls self care passwort ändern

Das ist der Bildtitel

Danke fürs Lesen !

#js #javascript