25
loading...
This website collects cookies to deliver better user experience
String myName; // Variable with a type of string
myName = "Tony Stark"; // The string is called Tony Stark
myName = 24; // Reassigning the string into a number
let myName; // Variable that has no type
myName = "Tony Stark"; // The variable has a type of string
myName = 24; // The variable has changed its type dynamically to a number
my_name = "Tony Stark" # The variable has a type of string
my_name = 24 # The variable has changed its type dynamically to an int
console.log
for outputting messages to the consolefunction myFunc() {
console.log('Hello World');
}
const myFunc2 = () => {
console.log('Hello World 2');
};
myFunc();
myFunc2();
print
for outputting messages to the consoledef my_func():
print('Hello World')
my_func()
let myName = "Tony Stark";
console.log(typeof myName); // string
my_name = "Tony Stark"
print(type(my_name)) # str
let num = 9000;
let num2 = 9.0;
console.log(typeof num); // Number
console.log(typeof num2); // Number
num = 9000
num_2 = 9.0
print(type(num)) # Int
print(type(num_2)) # Float
let wizard = true;
console.log(wizard); // boolean
wizard = True
print(wizard) # bool
const myprofile = {
name: 'Tony Stark',
age: 48,
superhero: 'Iron Man',
};
console.log(myprofile);
my_profile = {
"name": "Tony Stark",
"age": 48,
"superhero": "Iron Man",
};
print(my_profile);
const myArr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
console.log(typeof myArr); // object
myArr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
print(type(myArr)) # list