Skip to content

Instantly share code, notes, and snippets.

View heinthanth's full-sized avatar
Let me cook

Hein Thant heinthanth

Let me cook
View GitHub Profile
@heinthanth
heinthanth / typical-function.js
Last active September 1, 2019 05:21
Typical Function
function demo(foo, bar="baz") {
return foo + bar;
}
@heinthanth
heinthanth / replace.js
Last active September 1, 2019 04:36
string replace
var str = "Hello, John Doe!";
var result = str.replace("John Doe", "Hein Thanth");
// now result is "Hello, Hein Thanth!";
var str = "Kali Linux is for Hackers. Also, Kali Linux, which is Debian based. Black Arch Linux too!";
var result = str.replace("Kali Linux", "Parrot Sec OS");
@heinthanth
heinthanth / slice.js
Created September 1, 2019 04:27
slice
var str = "Hello, World";
var result = str.slice(3, 8);
// result become "lo, W";
@heinthanth
heinthanth / reverse-array.js
Created September 1, 2019 04:16
Array Reverse
var x = ["foo", "bar", "baz"];
x = x.reverse();
// now x become ["baz", "bar", "foo"];
@heinthanth
heinthanth / sort-burmese.js
Created September 1, 2019 04:14
Sort Burmese String
var x = ["ညီမလေး", "မေမေ", "ဖေဖေ", "ကိုကို"];
x = x.sort();
// now x become ["ကိုကို", "ညီမလေး", "ဖေဖေ", "မေမေ"];
@heinthanth
heinthanth / sort.js
Created September 1, 2019 04:11
sort
var x = ["c", "r", "o", "b"];
x = x.sort();
// now, x become ["b", "c", "o", "r"]
@heinthanth
heinthanth / continue.js
Created September 1, 2019 03:57
Continue
for(int i = 0; i < 6; i++) {
if(i == 3) {
continue;
}
// do something
}
@heinthanth
heinthanth / for-each.php
Created September 1, 2019 03:51
For Each
<?php
$x = [4, 5, 6, 7, 8];
foreach($x as $i) {
echo $i;
// will print 4, 5, 6, 7, 8 in each time since $i = $x[$i] in each time
}
@heinthanth
heinthanth / for-in.js
Created September 1, 2019 03:49
For-In
var x = [4, 5, 6, 7, 8];
for(var i in x) {
console.log(i);
// will log 4, 5, 6, 7, 8 in each time since i = x[i] in each time
}
@heinthanth
heinthanth / do-while.js
Created September 1, 2019 03:43
Do While
var x = 3;
do {
// will execute once although condition is x != 3
} while(x != 3);