fa
Feedback
Javascript Node Js basic to Advance

Javascript Node Js basic to Advance

رفتن به کانال در Telegram
1 176
مشترکین
اطلاعاتی وجود ندارد24 ساعت
-27 روز
-1130 روز
آرشیو پست ها
let a = require('axios'); let url = "https://example.com"; let e = " excecuted" a.get(url).then(r => console.log(0+e)); a.get(url).then(r => console.log(1+e)); a.get(url).then(r => console.log(2+e)); a.get(url).then(r => console.log(3+e)); a.get(url).then(r => console.log(4+e)); // this code demonstrates asynchronous programming here any line of code can be excecuted first

Learn about list many methods given above 👆you can run it by run button List is a type of array in js

// List means array but with some difference // Creating a List let my_list = []; console.log("Empty list:", my_list); my_list = [1, 2, 3, 4, 5]; console.log("List with initial values:", my_list); // Accessing List Elements let element = my_list[0]; console.log("Element at index 0:", element); let last_element = my_list[my_list.length - 1]; console.log("Last element:", last_element); // Modifying List Elements my_list[2] = 10; console.log("List after updating element at index 2:", my_list); // Adding Elements to the List my_list.push(6); console.log("List after appending element:", my_list); my_list.splice(3, 0, 7); console.log("List after inserting element at index 3:", my_list); let another_list = [8, 9, 10]; my_list = my_list.concat(another_list); console.log("List after extending with another list:", my_list); // Removing Elements from the List my_list = my_list.filter(item => item !== 4); console.log("List after removing element 4:", my_list); let removed_element = my_list.splice(2, 1); console.log("List after removing element at index 2:", my_list); console.log("Removed element:", removed_element[0]); // Clear list my_list = []; console.log("List after clearing all elements:", my_list); another_list = [8, 9, 10, 5, 7, 3, 9]; my_list = my_list.concat(another_list); console.log("List after extending with another list:", my_list); // Slicing a List let sliced_list = my_list.slice(1, 3); console.log("Sliced list from index 1 to 3 (exclusive):", sliced_list); // sub_list let sub_list = my_list.slice(2); console.log("Sublist from index 2 till the end:", sub_list); // reversed_list let reversed_list = my_list.reverse(); console.log("Reversed list:", reversed_list); // List Iteration my_list.forEach(element => { console.log("Element:", element); }); my_list.forEach((element, index) => { console.log("Index:", index, "Element:", element); }); // Code by @Python_Codes_Pro // buttons by @IOChannel_bot // Run by @Compiler0bot // for Group @CodeCompiler_Bot

// operation in float in js let num1 = 50.5 let num2 = 8.3 console.log("Given values ", num1, " and ", num2) console.log("\nSubtraction: ", num1 - num2) console.log("Addition: ", num1 + num2) console.log("Multiplication: ", num1 * num2) console.log("division: ", num1 / num2) // @jsCode0

// operation in integer in js let int1 = 50 let int2 = 8 console.log("Given values ", int1, " and ", int2) console.log("\nSubtraction: ", int1 - int2) console.log("Addition: ", int1 + int2) console.log("Multiplication: ", int1 * int2) console.log("division: ", int1 / int2) // @jsCode0

// integer declaration in js let num = 76 console.log(num)

// strings declaration in js let str = "its js strings" console.log(str)

// #5 Js function // js function which takes any value and shows them function show(value){   console.log(value) } // call show function with hello value show("Hello") // @jsCode0

Comment here👇👇

// #5 Js function // js function which takes any value and shows them function show(value){ console.log(value) } // call show function with hello value show("Hello") // @jsCode0

// #4 Js list (array) for storing many values // storing 3 values let jsArr = [2, 4, 6] // showing first value console.log( jsArr[0] ) // @jsCode0

// #3 Taking input in node js const readline = require('readline').createInterface({ input: process.stdin, output: process.stdout }); readline.question("Enter a number: ", (num) => { console.log("You entered: " + num); }); // @jsCode0

// #2 declaration of variables let a = 1 // block scoped variable var b = 2 // accessible from other blocks{} const c = 3 // constant variable // it insures that program will not assign any value to it again console.log("var1: " + a); console.log("var2: " + b); console.log("var3: " + c); // @JsCode0

// #1 for show print any value console.log("Hello, world!"); // first js program @JsCode0