khumam / fastcard Goto Github PK
View Code? Open in Web Editor NEWWe want to share from the community to the community various things related to developers, programming, engineering, and other related topics.
Home Page: https://fastcard.dev
We want to share from the community to the community various things related to developers, programming, engineering, and other related topics.
Home Page: https://fastcard.dev
Category
PHP
Title
Switch Operator
Description
The switch operator in PHP is a control flow statement that allows you to execute different code blocks based on the value of an expression. It is similar to a series of if-else statements, but it can be more efficient for comparing the same expression to multiple values.
Cards
To use the switch operator, you first need to define a variable or expression to be evaluated. Then, you use the switch statement to compare the value of the variable or expression to a list of case statements. If the value matches one of the case statements, the code block associated with that case statement is executed. If the value does not match any of the case statements, the default code block (if it exists) is executed.
<?php
$color = "red";
switch ($color) {
case "red":
echo "The color is red.";
break;
case "green":
echo "The color is green.";
break;
case "blue":
echo "The color is blue.";
break;
default:
echo "The color is unknown.";
}
// output: The color is red.
?>
Category
Programming Language
Title
Javascript
Description
Javascript merupakan bahasa pemrograman populer yang banyak digunakan untuk kebutuhan Frontend dan memberikan pengalaman yang baik ke pengguna. Javascript biasanya akan jalan secara otomatis di browser tanpa harus menginstall aplikasi apapun
Cards
Please write the content of your cards. The content should be in markdown format so we can add your content easily. Or you can see this example below.
File javascript bisa dibuat dengan ekstensi .js jika itu file yang terpisah dari HTML. Akan tetapi, juga bisa langsung diselipkan di dalam dokumen HTML dengan tag script. Jika filenya terpisah, bisa juga diimport dengan menggunakan tag yang sama yaitu script.
<!-- Import file .js -->
<script src="path/ke/file.js"></script>
<!-- Menulis langsung di HTML -->
<script>
// Langsung tulis file javascriptnya
</script>
\
Untuk inisialisasi variable Javascript, perlu aksesor diawalnya. Variable javascript tidak memerlukan simbol apapun dalam penulisannya. Hanya saja perlu diketahui bahwa penulisannya tetap mengikuti aturan penulisan variabel secara umum.
// Variabel konstan
const data = 'your value';
// Variabel bisa diubah secara global
var user = 'your value';
// Variabel bisa diubah di block tertentu
let number = 13;
\
Secara umum ada 3 aksesor yang harus dipahami. Yaitu const, var, dan let. Term conts digunakan untuk membuat variabel konstan yang tidak bisa diubah lagi nilainya kecuali diinisialisasi ulang. Term var dan let merupakan aksesor yang mana nilai variable bisa diubah, bedanya var bersifat global dan let bersifat lokal.
// Const variable
const number = 1;
number = 2; // error karena variable number itu constant
const number = 2; // bisa karena diinisialisasi ulang
// Var dan let
var name = 'Jhon';
function process() {
let age = 24;
return "My name is " + name + " and I am " + age + " years old";
// My name is Jhon and I am 24 years old
}
age = 21;
console.log("My name is " + name + " and I am " + age + " years old");
// My name is Jhon and I am undefined years old
\
Penggunaannya secara umum sama. Ada dengan menggunakan IF - ELSE IF - ELSEstatement ada juga yang menggunakan SWITCH Statement
// Menggunakan if - else if - else statement
if (condition) {
return true;
} else if (another_condition) {
return true;
} else {
return false;
}
// Menggunakan switch statement
switch(value) {
case condition:
return true;
break;
case another_condition:
return true;
break;
default:
return false;
}
\
Di dalam javascript, ada beberapa jenis perulangan, yang mana mungkin salah satunya sudah familiar. Yakni for loop, for in loop, for of loop, dan while loop.
\
Untuk for loop sama seperti di dalam bahasa pemrograman pada umumnya, Looping ini memiliki nilai awal, batasan akhir, dan kondisi looping yang sudah ditentukan.
for (initial_condition, final_condition, condition_behavior) {
// Your code
}
// Example
for (let index = 0; index < 10; index++) {
// your code will run 10x
}
\
Di dalam javascript, terdapat metode for in loop. Metode ini digunakan untuk mengambil key dari sebuah objek.
const data = { name: "Jhon", age: 24, address: "New York" };
let text = "";
for (key in data) {
text += data[key];
}
console.log(text);
// Jhon24New York
\
Untuk mengulang sebanyak panjang dari array atau objek yang diulang, kita bisa menggunakan For Of Loop.
const data = ['a', 'b', 'c'];
for (const element of data) {
console.log(element);
}
// Expected output: "a"
// Expected output: "b"
// Expected output: "c"
\
Untuk looping while loop cara penggunaannya sama seperti di bahasa pemrograman pada umumnya. Loop ini akan terus berjalan jika kondisi tidak bernilai false
while(condition) {
// your code here
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.