Skip to content

Instantly share code, notes, and snippets.

View patrickalgrim's full-sized avatar

Patrick Algrim patrickalgrim

View GitHub Profile
if (isEnabled) {
return “enabled”;
} else {
return “not enabled”;
}
return isEnabled ? “enabled” : “not enabled”;
var exampleFunction: boolean = function(x: string): boolean {
return x;
}
// we are prepending “private” variables with an underscore _
var MyExampleModule = function() {
var _privateVar = “Hello”;
return {
getPrivateVar: function() {
return _privateVar;
},
setPrivateVar: function(value) {
function hoistedFunctionExample() {
console.log(“hello world!”);
}
var z = 5;
function outer() {
var x = 0;
console.log(y, x, z);
// logs “undefined, 0, 5”. I am not within the same closure as y, but I am with x, z
function inner() {
var y = 1;
console.log(x, y, z), // logs “0, 1, 5”. I am in the closure with x, y, and z.
}
function sum(x) {
return function(y) {
return x + y;
};
};
<div class=”container”>
<div class=”row”>
<div class=”col-md-6”>Hello</div>
<div class=”col-md-6”>World</div>
</div>
</div>
int sum = Arrays.stream(new int[]{1, 2, 3})
.filter(i -> i >= 2)
.map(i -> i * 3)
.sum();
Thread thread = new Thread(new Runnable() {
public void run() {
System.out.println("Sample Expression");
}
});
public interface Vehicle {
public void move();
default void hoot() {
System.out.println("Sample");
}
}